summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/plist/plist.h8
-rw-r--r--src/plist.c15
2 files changed, 23 insertions, 0 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h
index 63e9d84..bba735d 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -288,6 +288,14 @@ extern "C"
void plist_array_remove_item(plist_t node, uint32_t n);
/**
+ * Remove a node that is a child node of a #PLIST_ARRAY node.
+ * node will be freed using #plist_free.
+ *
+ * @param node The node to be removed from its #PLIST_ARRAY parent.
+ */
+ void plist_array_item_remove(plist_t node);
+
+ /**
* Create an iterator of a #PLIST_ARRAY node.
* The allocated iterator should be freed with the standard free function.
*
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)