feat: open(2), close(2), mkdir(2) and readdir(2) syscall
[lunaix-os.git] / lunaix-os / libs / hash.c
index 293ec67bc3bddb6d7a450e09e32009c5f827f4e3..c1580edda5a51074ea9237abe709eeaddac55cb3 100644 (file)
 uint32_t
 strhash_32(unsigned 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);