summaryrefslogtreecommitdiffstats
path: root/src/plist.c
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-02-14 17:32:19 +0100
committerGravatar Jonathan Beck2009-02-14 17:32:19 +0100
commitaa3a4c8d45be9da585d1aae141a546cfbbdf509f (patch)
tree5924d46f2392127fa75272daa99e85fc73c9e9bf /src/plist.c
parent461c947d1238a1ca5604ec34bd4fe84e040334f7 (diff)
downloadlibplist-aa3a4c8d45be9da585d1aae141a546cfbbdf509f.tar.gz
libplist-aa3a4c8d45be9da585d1aae141a546cfbbdf509f.tar.bz2
Fix some memory leaks.
Diffstat (limited to 'src/plist.c')
-rw-r--r--src/plist.c16
1 files changed, 14 insertions, 2 deletions
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);
}