From a9880a6f40ed6f55bc56d7f59c5f88a6718e8549 Mon Sep 17 00:00:00 2001 From: bpc2003 Date: Fri, 14 Mar 2025 11:48:03 -0400 Subject: Update Makefile --- src/lib/keytab.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/lib/keytab.c') diff --git a/src/lib/keytab.c b/src/lib/keytab.c index 74dc47f..ed61264 100644 --- a/src/lib/keytab.c +++ b/src/lib/keytab.c @@ -29,12 +29,12 @@ struct keytab getkey(struct keytablist *list, int id, char *key) { int idx = hash(key); if (list[id].tab[idx].key == NULL) - return (struct keytab) { .key = NULL, .flag = 0, .v = 0 }; + return (struct keytab) { .key = NULL, .flag = 0, .v = { 0 } }; while (strcmp(list[id].tab[idx].key, key) && idx < TABLEN) idx++; if (idx >= TABLEN) - return (struct keytab) { .key = NULL, .flag = 0, .v = 0 }; + return (struct keytab) { .key = NULL, .flag = 0, .v = { 0 } }; return list[id].tab[idx]; } @@ -83,8 +83,11 @@ int setkey(struct keytablist **list, int id, char *pair) } if (!(*list)[id].tab[idx].key) (*list)[id].tab[idx].key = key; - else + else { free(key); + if ((*list)[id].tab[idx].flag == 3) + free((*list)[id].tab[idx].v.str); + } (*list)[id].tab[idx].v = v; (*list)[id].tab[idx].flag = flag; return 0; -- cgit v1.2.3