summaryrefslogtreecommitdiffstats
path: root/src/plist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plist.c')
-rw-r--r--src/plist.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/plist.c b/src/plist.c
index dcaf601..e077ad9 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -446,6 +446,33 @@ void plist_dict_remove_item(plist_t node, const char* key)
446 return; 446 return;
447} 447}
448 448
449void plist_dict_merge(plist_t *target, plist_t source)
450{
451 if (!target || !*target || (plist_get_node_type(*target) != PLIST_DICT) || !source || (plist_get_node_type(source) != PLIST_DICT))
452 return;
453
454 char* key = NULL;
455 plist_dict_iter it = NULL;
456 plist_t subnode = NULL;
457 plist_dict_new_iter(source, &it);
458 if (!it)
459 return;
460
461 do {
462 plist_dict_next_item(source, it, &key, &subnode);
463 if (!key)
464 break;
465
466 if (plist_dict_get_item(*target, key) != NULL)
467 plist_dict_remove_item(*target, key);
468
469 plist_dict_insert_item(*target, key, plist_copy(subnode));
470 free(key);
471 key = NULL;
472 } while (1);
473 free(it);
474}
475
449plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v) 476plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v)
450{ 477{
451 plist_t current = plist; 478 plist_t current = plist;