X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=util.c;h=1db33667d041d33278428e578d5685b771b0ee19;hp=d44114d7fa52feeeae92eb177df577763cd11d08;hb=853f586e4894aba060372b4655334921cda10464;hpb=82db7b24855fbf5815d059c7cf6ab5f3f4ee44f0;ds=sidebyside diff --git a/util.c b/util.c index d44114d..1db3366 100644 --- a/util.c +++ b/util.c @@ -16,6 +16,7 @@ * This file contains misc utility functions and wrappers to standard * functions, which throw exceptions upon failure. */ +#define _GNU_SOURCE #include #include #include @@ -24,6 +25,11 @@ #include #include #include +#include +#include + +#include "uci.h" +#include "uci_internal.h" __plugin void *uci_malloc(struct uci_context *ctx, size_t size) { @@ -57,22 +63,6 @@ __plugin char *uci_strdup(struct uci_context *ctx, const char *str) return ptr; } -/* 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); -} - /* * validate strings for names and types, reject special characters * for names, only alphanum and _ is allowed (shell compatibility)