X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=blobdiff_plain;f=version2%2Fsrc%2FC%2FIoTString.h;h=1fb527f03a9977233377a1796c0c2c47e656993c;hp=cb2d68b1af6dd13ddebf8ebcf2f95faef0bca912;hb=b2bc9b5c707bd7d932d60cd4e8c1cb580b36b5b4;hpb=15acb678f516190fbf7364a41a1f570e90dc09d0 diff --git a/version2/src/C/IoTString.h b/version2/src/C/IoTString.h index cb2d68b..1fb527f 100644 --- a/version2/src/C/IoTString.h +++ b/version2/src/C/IoTString.h @@ -9,9 +9,9 @@ * @version 1.0 */ -inline int hashCharArray(Array *array) { +inline unsigned int hashCharArray(Array *array) { uint len = array->length(); - int hash = 0; + unsigned int hash = 0; for (uint i = 0; i < len; i++) { hash = 31 * hash + array->get(i); } @@ -22,7 +22,7 @@ class IoTString { private: Array *array; IoTString() {} - int hashvalue; + unsigned int hashvalue; /** * Builds an IoTString object around the char array. This * constructor makes a copy, so the caller is free to modify the char array. @@ -37,7 +37,7 @@ public: IoTString(const char *_array) { int32_t len = strlen(_array); array = new Array(len); - strcpy(array->internalArray(), _array); + memcpy(array->internalArray(), _array, len); hashvalue = hashCharArray(array); } @@ -51,7 +51,7 @@ public: } char get(uint i) {return array->get(i);} - + /** * Internal method to grab a reference to our char array. Caller * must not modify it. @@ -79,7 +79,7 @@ public: return result == 0; } - int hashValue() { return hashvalue;} + unsigned int hashValue() { return hashvalue;} int length() { return array->length(); } friend IoTString *IoTString_shallow(Array *_array); }; @@ -90,7 +90,7 @@ inline IoTString *IoTString_shallow(Array *_array) { return str; } -inline int hashString(IoTString *a) { +inline unsigned int hashString(IoTString *a) { return a->hashValue(); }