commit - c6f9745ecc2be61996aecd22e87e9e028eef1907
commit + 72d0ec484e076adae167151a54af4e58ad39b647
blob - d14b04eed473e9ae7b3a22dfdca6431d1ed5174c
blob + cb42223006577b8071076b8753890c9fe56df50e
--- table_static.c
+++ table_static.c
};
struct kp {
- char *key;
char *val;
+ char key[];
};
static void *
struct kp *kp;
unsigned int slot;
- kp = xcalloc(1, sizeof(*kp));
- kp->key = xstrdup(key);
+ if (key == NULL)
+ return -1;
+
+ kp = xcalloc(1, sizeof(*kp) + strlen(key) + 1);
+ strcpy(kp->key, key);
if (val != NULL)
kp->val = xstrdup(val);
struct kp *kp;
unsigned int slot;
-#if 0
slot = ohash_qlookup(t->t_handle, key);
if ((kp = ohash_find(t->t_handle, slot)) == NULL)
return -1;
*ret_val = xstrdup(kp->val);
return 0;
-#endif
-
- for (kp = ohash_first(t->t_handle, &slot);
- kp != NULL;
- kp = ohash_next(t->t_handle, &slot)) {
- if (!strcmp(kp->key, key)) {
- *ret_val = xstrdup(kp->val);
- return 0;
- }
- }
- return -1;
}
static void