tree data OPTIMIZE added first_sibling parameter
This change avoids unnecessary finding of the first sibling in case
the parent node is not available.
diff --git a/src/tree_data_free.c b/src/tree_data_free.c
index d76a4aa..32d32cc 100644
--- a/src/tree_data_free.c
+++ b/src/tree_data_free.c
@@ -267,7 +267,7 @@
static void
lyd_free_(struct lyd_node *node)
{
- struct lyd_node *iter, *next;
+ struct lyd_node *iter, *next, *first_sibling = NULL;
if (!node) {
return;
@@ -282,7 +282,7 @@
/* in case of the top-level nodes (node->parent is NULL), no unlinking needed */
if (iter->parent) {
lyds_free_metadata(iter);
- lyd_unlink_ignore_lyds(iter);
+ lyd_unlink_ignore_lyds(&first_sibling, iter);
}
lyd_free_subtree(iter);
}