summaryrefslogtreecommitdiffstats
path: root/libcnary/node.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-04-24 01:10:46 +0200
committerGravatar Nikias Bassen2012-04-24 01:10:46 +0200
commit6697e4927883843e1bd537d778fc58bebd9a0b4e (patch)
tree833289631dc5f4db12399b0e32f623d757957800 /libcnary/node.c
parent7060250b7583ad9cd20007b6fda5dcf068d55cbe (diff)
downloadlibplist-6697e4927883843e1bd537d778fc58bebd9a0b4e.tar.gz
libplist-6697e4927883843e1bd537d778fc58bebd9a0b4e.tar.bz2
libcnary: return removed/detached index in node_list_remove/node_detach
Diffstat (limited to 'libcnary/node.c')
-rw-r--r--libcnary/node.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libcnary/node.c b/libcnary/node.c
index 264c78e..0a8f414 100644
--- a/libcnary/node.c
+++ b/libcnary/node.c
@@ -95,11 +95,12 @@ int node_attach(node_t* parent, node_t* child) {
}
int node_detach(node_t* parent, node_t* child) {
- if (!parent || !child) return 0;
- if (node_list_remove(parent->children, child) == 0) {
+ if (!parent || !child) return -1;
+ int index = node_list_remove(parent->children, child);
+ if (index >= 0) {
parent->count--;
}
- return 0;
+ return index;
}
int node_insert(node_t* parent, unsigned int index, node_t* child)