diff --git a/libpkgconf/tuple.c b/libpkgconf/tuple.c index 6fbd0d6..2bcadc2 100644 --- a/libpkgconf/tuple.c +++ b/libpkgconf/tuple.c @@ -59,11 +59,30 @@ out: free(workbuf); } +static void +pkgconf_tuple_find_delete(pkgconf_list_t *list, const char *key) +{ + pkgconf_node_t *node, *next; + + PKGCONF_FOREACH_LIST_ENTRY_SAFE(list->head, next, node) + { + pkgconf_tuple_t *tuple = node->data; + + if (!strcmp(tuple->key, key)) + { + pkgconf_tuple_free_entry(tuple, list); + return; + } + } +} + pkgconf_tuple_t * pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key, const char *value, bool parse) { pkgconf_tuple_t *tuple = calloc(sizeof(pkgconf_tuple_t), 1); + pkgconf_tuple_find_delete(list, key); + tuple->key = strdup(key); if (parse) tuple->value = pkgconf_tuple_parse(client, list, value);