* If the #GTree was created using g_tree_new_full(), the key and value
* are freed using the supplied destroy functions, otherwise you have to
* make sure that any dynamically allocated values are freed yourself.
+ * Note that if the key existed in
+ * earlier versions of the tree (g_tree_next_version() has been called since
+ * it was inserted), then it cannot be removed from the tree. *
* If the key does not exist in the #GTree, the function does nothing.
*
- * Returns: %TRUE if the key was found (prior to 2.8, this function returned
- * nothing)
+ * Returns: %TRUE if the key was found and able to be removed
+ * (prior to 2.8, this function returned nothing)
**/
gboolean
g_tree_remove (GTree *tree,
* @key: the key to remove.
*
* Removes a key and its associated value from a #GTree without calling
- * the key and value destroy functions.
- *
+ * the key and value destroy functions. Note that if the key existed in
+ * earlier versions of the tree (g_tree_next_version() has been called since
+ * it was inserted), then it cannot be removed from the tree. *
* If the key does not exist in the #GTree, the function does nothing.
*
- * Returns: %TRUE if the key was found (prior to 2.8, this function returned
- * nothing)
+ * Returns: %TRUE if the key was found and able to be removed
+ * (prior to 2.8, this function returned nothing)
**/
gboolean
g_tree_steal (GTree *tree,
}
}
+ tree->nnodes--;
+
/* only really delete the node if it's in the current version, otherwise
it needs to be remembered */
if (node->nv == 1 && node->version(NOW) == tree->version)
(node->version(NOW) == 0 ? 1 : MAX_IN_DEGREE + 1),
node->v);
g_slice_free (GTreeNode, node);
- }
- tree->nnodes--;
+ return TRUE;
+ }
- return TRUE;
+ return FALSE;
}
/**