summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-05-19 01:22:04 +0200
committerGravatar Nikias Bassen2019-05-19 01:22:04 +0200
commit9555e71d9887d0d5caf87341dc47d9ad313bb609 (patch)
treef1168779ed3931c57382533426b39e65d0d5869b /src
parent23e5a7636bba1565d000adcd4c3debc0788398c5 (diff)
downloadlibplist-9555e71d9887d0d5caf87341dc47d9ad313bb609.tar.gz
libplist-9555e71d9887d0d5caf87341dc47d9ad313bb609.tar.bz2
Add plist_array_item_remove() to allow removing an array's child node without relying on the index
Diffstat (limited to 'src')
-rw-r--r--src/plist.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/plist.c b/src/plist.c
index 3ffedc4..dd659b8 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -515,6 +515,21 @@ PLIST_API void plist_array_remove_item(plist_t node, uint32_t n)
return;
}
+PLIST_API void plist_array_item_remove(plist_t node)
+{
+ plist_t father = plist_get_parent(node);
+ if (PLIST_ARRAY == plist_get_node_type(father))
+ {
+ int n = node_child_position(father, node);
+ if (n < 0) return;
+ ptrarray_t* pa = ((plist_data_t)((node_t*)father)->data)->hashtable;
+ if (pa) {
+ ptr_array_remove(pa, n);
+ }
+ plist_free(node);
+ }
+}
+
PLIST_API void plist_array_new_iter(plist_t node, plist_array_iter *iter)
{
if (iter)