summaryrefslogtreecommitdiff
path: root/src/lib/getkeys.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/getkeys.c')
-rw-r--r--src/lib/getkeys.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/getkeys.c b/src/lib/getkeys.c
index 98442a3..cdba202 100644
--- a/src/lib/getkeys.c
+++ b/src/lib/getkeys.c
@@ -4,8 +4,9 @@
#include <threads.h>
#include "mdb.h"
+#include "utils.h"
-extern tabidx_t getkey(tablist_t *list, int id, char *key);
+static tabidx_t getkey(tablist_t *list, int id, char *key);
static int getkeys_helper(void *data);
@@ -89,3 +90,16 @@ static struct params *pass(tablist_t *list, tablist_t *ret, char **keys, int len
p->pid = pid;
return p;
}
+
+static tabidx_t getkey(tablist_t *list, int id, char *key)
+{
+ int idx = hash(key);
+ if (list[id].tab[idx].key == NULL)
+ return (tabidx_t) { .key = NULL, .flag = 0, .value = { 0 } };
+
+ while (strcmp(list[id].tab[idx].key, key) && idx < TABLEN)
+ idx++;
+ if (idx >= TABLEN)
+ return (tabidx_t) { .key = NULL, .flag = 0, .value = { 0 } };
+ return list[id].tab[idx];
+}