diff options
Diffstat (limited to 'src/plist.c')
| -rw-r--r-- | src/plist.c | 16 |
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() | |||
| 44 | return data; | 44 | return data; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | void plist_free_plist_data(plist_data_t data) | 47 | static void plist_free_node(GNode * node, gpointer none) |
| 48 | { | 48 | { |
| 49 | plist_data_t data = plist_get_data(node); | ||
| 49 | if (data) { | 50 | if (data) { |
| 50 | switch (data->type) { | 51 | switch (data->type) { |
| 51 | 52 | case PLIST_KEY: | |
| 53 | case PLIST_STRING: | ||
| 54 | free(data->strval); | ||
| 55 | break; | ||
| 56 | case PLIST_UNICODE: | ||
| 57 | free(data->unicodeval); | ||
| 58 | break; | ||
| 59 | case PLIST_DATA: | ||
| 60 | free(data->buff); | ||
| 61 | break; | ||
| 52 | default: | 62 | default: |
| 53 | break; | 63 | break; |
| 54 | } | 64 | } |
| 55 | free(data); | 65 | free(data); |
| 56 | } | 66 | } |
| 67 | node->data = NULL; | ||
| 57 | } | 68 | } |
| 58 | 69 | ||
| 59 | plist_t plist_new_dict() | 70 | plist_t plist_new_dict() |
| @@ -133,6 +144,7 @@ static plist_t plist_add_sub_element(plist_t node, plist_type type, const void * | |||
| 133 | 144 | ||
| 134 | void plist_free(plist_t plist) | 145 | void plist_free(plist_t plist) |
| 135 | { | 146 | { |
| 147 | g_node_children_foreach(plist, G_TRAVERSE_ALL, plist_free_node, NULL); | ||
| 136 | g_node_destroy(plist); | 148 | g_node_destroy(plist); |
| 137 | } | 149 | } |
| 138 | 150 | ||
