libpkgconf: tuple: add pkgconf_tuple_free_entry() to free a specific tuple node

feature/tap-sh
William Pitcock 2016-12-09 20:50:33 -06:00
parent 02ec215ecc
commit f7b7853932
2 changed files with 12 additions and 7 deletions

View File

@ -242,6 +242,7 @@ pkgconf_tuple_t *pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_
char *pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key); char *pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key);
char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *list, const char *value); char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *list, const char *value);
void pkgconf_tuple_free(pkgconf_list_t *list); void pkgconf_tuple_free(pkgconf_list_t *list);
void pkgconf_tuple_free_entry(pkgconf_tuple_t *tuple, pkgconf_list_t *list);
void pkgconf_tuple_add_global(pkgconf_client_t *client, const char *key, const char *value); void pkgconf_tuple_add_global(pkgconf_client_t *client, const char *key, const char *value);
char *pkgconf_tuple_find_global(const pkgconf_client_t *client, const char *key); char *pkgconf_tuple_find_global(const pkgconf_client_t *client, const char *key);
void pkgconf_tuple_free_global(pkgconf_client_t *client); void pkgconf_tuple_free_global(pkgconf_client_t *client);

View File

@ -155,17 +155,21 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const
return strdup(buf); return strdup(buf);
} }
void
pkgconf_tuple_free_entry(pkgconf_tuple_t *tuple, pkgconf_list_t *list)
{
pkgconf_node_delete(&tuple->iter, list);
free(tuple->key);
free(tuple->value);
free(tuple);
}
void void
pkgconf_tuple_free(pkgconf_list_t *list) pkgconf_tuple_free(pkgconf_list_t *list)
{ {
pkgconf_node_t *node, *next; pkgconf_node_t *node, *next;
PKGCONF_FOREACH_LIST_ENTRY_SAFE(list->head, next, node) PKGCONF_FOREACH_LIST_ENTRY_SAFE(list->head, next, node)
{ pkgconf_tuple_free_entry(node->data, list);
pkgconf_tuple_t *tuple = node->data;
free(tuple->key);
free(tuple->value);
free(tuple);
}
} }