summaryrefslogtreecommitdiff
path: root/list.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-08-20 14:56:30 +0200
committerFelix Fietkau <nbd@openwrt.org>2010-08-20 14:56:30 +0200
commit853f586e4894aba060372b4655334921cda10464 (patch)
tree44993506b7d917e69e51b91b20f58230032ff56a /list.c
parent82db7b24855fbf5815d059c7cf6ab5f3f4ee44f0 (diff)
downloaduci-853f586e4894aba060372b4655334921cda10464.tar.gz
split off and compile util.c separately
Diffstat (limited to 'list.c')
-rw-r--r--list.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/list.c b/list.c
index fb9d38a..1a080fa 100644
--- a/list.c
+++ b/list.c
@@ -127,6 +127,22 @@ uci_alloc_list(struct uci_section *s, const char *name)
return o;
}
+/* Based on an efficient hash function published by D. J. Bernstein */
+static unsigned int djbhash(unsigned int hash, char *str)
+{
+ int len = strlen(str);
+ int i;
+
+ /* initial value */
+ if (hash == ~0)
+ hash = 5381;
+
+ for(i = 0; i < len; i++) {
+ hash = ((hash << 5) + hash) + str[i];
+ }
+ return (hash & 0x7FFFFFFF);
+}
+
/* fix up an unnamed section, e.g. after adding options to it */
__private void uci_fixup_section(struct uci_context *ctx, struct uci_section *s)
{