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

20 lines
324 B
C
Raw Normal View History

2010-09-22 17:25:19 +02:00
#include <string.h>
#include "hash_string.h"
unsigned long hash_string(unsigned char *str)
{
unsigned long hash = 5381;
int c;
while ((c = *str++)) {
2013-06-22 17:58:19 +02:00
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
}
2010-09-22 17:25:19 +02:00
return hash;
}
2013-06-22 17:58:19 +02:00
int cmp_string(char *a, char *b)
{
return (strcmp(a, b) == 0);
2010-09-22 17:25:19 +02:00
}