diff options
| -rw-r--r-- | src/plist.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/plist.c b/src/plist.c index 6a267eb..8c2866d 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -325,10 +325,7 @@ static void plist_copy_node(node_t *node, void *parent_node_ptr) | |||
| 325 | memcpy(newdata, data, sizeof(struct plist_data_s)); | 325 | memcpy(newdata, data, sizeof(struct plist_data_s)); |
| 326 | 326 | ||
| 327 | node_type = plist_get_node_type(node); | 327 | node_type = plist_get_node_type(node); |
| 328 | if (node_type == PLIST_DATA || node_type == PLIST_STRING || node_type == PLIST_KEY) | 328 | switch (node_type) { |
| 329 | { | ||
| 330 | switch (node_type) | ||
| 331 | { | ||
| 332 | case PLIST_DATA: | 329 | case PLIST_DATA: |
| 333 | newdata->buff = (uint8_t *) malloc(data->length); | 330 | newdata->buff = (uint8_t *) malloc(data->length); |
| 334 | memcpy(newdata->buff, data->buff, data->length); | 331 | memcpy(newdata->buff, data->buff, data->length); |
| @@ -337,9 +334,22 @@ static void plist_copy_node(node_t *node, void *parent_node_ptr) | |||
| 337 | case PLIST_STRING: | 334 | case PLIST_STRING: |
| 338 | newdata->strval = strdup((char *) data->strval); | 335 | newdata->strval = strdup((char *) data->strval); |
| 339 | break; | 336 | break; |
| 337 | case PLIST_DICT: | ||
| 338 | if (data->hashtable) { | ||
| 339 | hashtable_t* ht = hash_table_new(dict_key_hash, dict_key_compare, NULL); | ||
| 340 | assert(ht); | ||
| 341 | plist_t current = NULL; | ||
| 342 | for (current = (plist_t)node_first_child(node); | ||
| 343 | ht && current; | ||
| 344 | current = (plist_t)node_next_sibling(node_next_sibling(current))) | ||
| 345 | { | ||
| 346 | hash_table_insert(ht, ((node_t*)current)->data, node_next_sibling(current)); | ||
| 347 | } | ||
| 348 | newdata->hashtable = ht; | ||
| 349 | } | ||
| 350 | break; | ||
| 340 | default: | 351 | default: |
| 341 | break; | 352 | break; |
| 342 | } | ||
| 343 | } | 353 | } |
| 344 | newnode = plist_new_node(newdata); | 354 | newnode = plist_new_node(newdata); |
| 345 | 355 | ||
