From aa3a4c8d45be9da585d1aae141a546cfbbdf509f Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Sat, 14 Feb 2009 17:32:19 +0100 Subject: Fix some memory leaks. --- src/plist.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/plist.c') diff --git a/src/plist.c b/src/plist.c index 87a1de5..c69f4c1 100644 --- a/src/plist.c +++ b/src/plist.c @@ -44,16 +44,27 @@ plist_data_t plist_new_plist_data() return data; } -void plist_free_plist_data(plist_data_t data) +static void plist_free_node(GNode * node, gpointer none) { + plist_data_t data = plist_get_data(node); if (data) { switch (data->type) { - + case PLIST_KEY: + case PLIST_STRING: + free(data->strval); + break; + case PLIST_UNICODE: + free(data->unicodeval); + break; + case PLIST_DATA: + free(data->buff); + break; default: break; } free(data); } + node->data = NULL; } plist_t plist_new_dict() @@ -133,6 +144,7 @@ static plist_t plist_add_sub_element(plist_t node, plist_type type, const void * void plist_free(plist_t plist) { + g_node_children_foreach(plist, G_TRAVERSE_ALL, plist_free_node, NULL); g_node_destroy(plist); } -- cgit v1.1-32-gdbae