X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/4769a870917b98723690aa336d12d0656769528b..af8e873ae38b72a56a89485c62bb5ccd22a9f8a7:/lunaix-os/libs/hash.c diff --git a/lunaix-os/libs/hash.c b/lunaix-os/libs/hash.c index 293ec67..277efb3 100644 --- a/lunaix-os/libs/hash.c +++ b/lunaix-os/libs/hash.c @@ -9,12 +9,15 @@ * @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; - while (c = *str++) + while ((c = *str++)) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ return hash >> (HASH_SIZE_BITS - truncate_to);