2014-02-06 16:55:35 +01:00
|
|
|
/**
|
|
|
|
* Hash string implementation
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* @ingroup sys_lib
|
|
|
|
* @{
|
|
|
|
* @file
|
|
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
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;
|
|
|
|
|
2013-06-24 22:37:35 +02:00
|
|
|
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
|
|
|
}
|