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
fix: symlink resolve.
[lunaix-os.git]
/
lunaix-os
/
libs
/
hash.c
diff --git
a/lunaix-os/libs/hash.c
b/lunaix-os/libs/hash.c
index 293ec67bc3bddb6d7a450e09e32009c5f827f4e3..277efb32eaf8370fc8f265ef8038ce4d1960004f 100644
(file)
--- a/
lunaix-os/libs/hash.c
+++ b/
lunaix-os/libs/hash.c
@@
-9,12
+9,15
@@
* @return unsigned int
*/
uint32_t
* @return unsigned int
*/
uint32_t
-strhash_32(
unsigned
char* str, uint32_t truncate_to)
+strhash_32(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);