diff options
| -rw-r--r-- | include/plist/plist.h | 8 | ||||
| -rw-r--r-- | src/plist.c | 15 |
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" | |||
| 288 | void plist_array_remove_item(plist_t node, uint32_t n); | 288 | void plist_array_remove_item(plist_t node, uint32_t n); |
| 289 | 289 | ||
| 290 | /** | 290 | /** |
| 291 | * Remove a node that is a child node of a #PLIST_ARRAY node. | ||
| 292 | * node will be freed using #plist_free. | ||
| 293 | * | ||
| 294 | * @param node The node to be removed from its #PLIST_ARRAY parent. | ||
| 295 | */ | ||
| 296 | void plist_array_item_remove(plist_t node); | ||
| 297 | |||
| 298 | /** | ||
| 291 | * Create an iterator of a #PLIST_ARRAY node. | 299 | * Create an iterator of a #PLIST_ARRAY node. |
| 292 | * The allocated iterator should be freed with the standard free function. | 300 | * The allocated iterator should be freed with the standard free function. |
| 293 | * | 301 | * |
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) | |||
| 515 | return; | 515 | return; |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | PLIST_API void plist_array_item_remove(plist_t node) | ||
| 519 | { | ||
| 520 | plist_t father = plist_get_parent(node); | ||
| 521 | if (PLIST_ARRAY == plist_get_node_type(father)) | ||
| 522 | { | ||
| 523 | int n = node_child_position(father, node); | ||
| 524 | if (n < 0) return; | ||
| 525 | ptrarray_t* pa = ((plist_data_t)((node_t*)father)->data)->hashtable; | ||
| 526 | if (pa) { | ||
| 527 | ptr_array_remove(pa, n); | ||
| 528 | } | ||
| 529 | plist_free(node); | ||
| 530 | } | ||
| 531 | } | ||
| 532 | |||
| 518 | PLIST_API void plist_array_new_iter(plist_t node, plist_array_iter *iter) | 533 | PLIST_API void plist_array_new_iter(plist_t node, plist_array_iter *iter) |
| 519 | { | 534 | { |
| 520 | if (iter) | 535 | if (iter) |
