feat: ability to manipulate extended attribute
[lunaix-os.git] / lunaix-os / libs / hash.c
index 293ec67bc3bddb6d7a450e09e32009c5f827f4e3..dc1b3ccb1c1af2f9e537457a6fc8b01637b472c5 100644 (file)
@@ -9,12 +9,15 @@
  * @return unsigned int
  */
 uint32_t
-strhash_32(unsigned char* str, uint32_t truncate_to)
+strhash_32(const char* str, uint32_t truncate_to)
 {
+    if (!str)
+        return 0;
+
     uint32_t hash = 5381;
     int c;
 
-    while (c = *str++)
+    while ((c = *str++))
         hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
 
     return hash >> (HASH_SIZE_BITS - truncate_to);