diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hashtable.c | 20 | ||||
-rw-r--r-- | lib/qsort.c | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/hashtable.c b/lib/hashtable.c index b47f3b6..9f069c0 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -202,6 +202,26 @@ void hdestroy_r(struct hsearch_data *htab) * example for functions like hdelete(). */ +int hmatch_r(const char *match, int last_idx, ENTRY ** retval, + struct hsearch_data *htab) +{ + unsigned int idx; + size_t key_len = strlen(match); + + for (idx = last_idx + 1; idx < htab->size; ++idx) { + if (!htab->table[idx].used) + continue; + if (!strncmp(match, htab->table[idx].entry.key, key_len)) { + *retval = &htab->table[idx].entry; + return idx; + } + } + + __set_errno(ESRCH); + *retval = NULL; + return 0; +} + int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval, struct hsearch_data *htab) { diff --git a/lib/qsort.c b/lib/qsort.c index e771dcf..1cc0d31 100644 --- a/lib/qsort.c +++ b/lib/qsort.c @@ -16,6 +16,7 @@ * bcc and gcc. */ #include <linux/types.h> +#include <exports.h> #if 0 #include <assert.h> #else @@ -67,3 +68,8 @@ void qsort(void *base, } while (wgap); } } + +int strcmp_compar(const void *p1, const void *p2) +{ + return strcmp(*(const char **)p1, *(const char **)p2); +} |