/** * Hash string implementation * * Copyright (C) 2013 Kaspar Schleiser * * 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 * @} */ #include #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); }