summaryrefslogtreecommitdiffstats
path: root/src/plist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plist.c')
-rw-r--r--src/plist.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/plist.c b/src/plist.c
index cd563aa..c205d46 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -139,7 +139,7 @@ void plist_free(plist_t plist)
139 g_node_destroy(plist); 139 g_node_destroy(plist);
140} 140}
141 141
142static void plist_copy_node(GNode * node, gpointer parent_node) 142static void plist_copy_node(GNode * node, gpointer parent_node_ptr)
143{ 143{
144 plist_t newnode = NULL; 144 plist_t newnode = NULL;
145 plist_data_t data = plist_get_data(node); 145 plist_data_t data = plist_get_data(node);
@@ -150,15 +150,21 @@ static void plist_copy_node(GNode * node, gpointer parent_node)
150 memcpy(newdata, data, sizeof(struct plist_data_s)); 150 memcpy(newdata, data, sizeof(struct plist_data_s));
151 newnode = plist_new_node(newdata); 151 newnode = plist_new_node(newdata);
152 152
153 if (parent_node) { 153 if (*(plist_t*)parent_node_ptr) {
154 g_node_append(parent_node, newnode); 154 g_node_append(*(plist_t*)parent_node_ptr, newnode);
155 } 155 }
156 g_node_children_foreach(node, G_TRAVERSE_ALL, plist_copy_node, newnode); 156 else {
157 *(plist_t*)parent_node_ptr = newnode;
158 }
159
160 g_node_children_foreach(node, G_TRAVERSE_ALL, plist_copy_node, &newnode);
157} 161}
158 162
159plist_t plist_copy(plist_t node) 163plist_t plist_copy(plist_t node)
160{ 164{
161 plist_copy_node(node, NULL); 165 plist_t copied = NULL;
166 plist_copy_node(node, &copied);
167 return copied;
162} 168}
163 169
164plist_t plist_get_first_child(plist_t node) 170plist_t plist_get_first_child(plist_t node)