1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/lib/hash_string.c
2010-09-22 17:25:19 +02:00

18 lines
312 B
C
Executable File

#include <string.h>
#include "hash_string.h"
unsigned long hash_string(unsigned char *str)
{
unsigned long hash = 5381;
int c;
while ((c = *str++))
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash;
}
int cmp_string(char* a, char* b) {
return (strcmp(a,b) == 0);
}