git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: open(2), close(2), mkdir(2) and readdir(2) syscall
[lunaix-os.git]
/
lunaix-os
/
libs
/
hash.c
diff --git
a/lunaix-os/libs/hash.c
b/lunaix-os/libs/hash.c
index 293ec67bc3bddb6d7a450e09e32009c5f827f4e3..c1580edda5a51074ea9237abe709eeaddac55cb3 100644
(file)
--- a/
lunaix-os/libs/hash.c
+++ b/
lunaix-os/libs/hash.c
@@
-11,10
+11,13
@@
uint32_t
strhash_32(unsigned char* str, uint32_t truncate_to)
{
uint32_t
strhash_32(unsigned char* str, uint32_t truncate_to)
{
+ if (!str)
+ return 0;
+
uint32_t hash = 5381;
int c;
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);
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash >> (HASH_SIZE_BITS - truncate_to);