summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorbpc2003 <wpesfriendnva@gmail.com>2025-03-14 11:48:03 -0400
committerbpc2003 <wpesfriendnva@gmail.com>2025-03-14 11:48:03 -0400
commita9880a6f40ed6f55bc56d7f59c5f88a6718e8549 (patch)
tree8e916c206c80d24a2da7655e3b2736356fec1c1e /src/lib
parentaa9bb5d3f1f7059bd9dd69d6b5f99acd68d439c2 (diff)
Update Makefile
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/keytab.c9
1 files changed, 6 insertions, 3 deletions
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;