X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=list.c;h=1a080fa9000d68d4f726e9ae17db5b2301b36bf5;hp=fb9d38a6ad6afaa6d4de3ecfe338cb1e488b3fbe;hb=853f586e4894aba060372b4655334921cda10464;hpb=6ce771b1095c220f849e70cdcbf23bd09f7fe7d5 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) {