data tree CHANGE improve lyd_insert(), lyd_insert_after() and lyd_insert_before()
Make the functions more smarter to be able to replace the implicit default
nodes instead of just adding the new nodes next to the previously automaticaly
created implicit default nodes.
lyd_insert() also supports smart inserting of a key into a list - it is able to
put the key into a correct position.
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 83f73eb..8a63062 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -3195,3 +3195,17 @@
}
}
}
+
+int
+lys_is_key(struct lys_node_list *list, struct lys_node_leaf *leaf)
+{
+ uint8_t i;
+
+ for (i = 0; i < list->keys_size; i++) {
+ if (list->keys[i] == leaf) {
+ return i + 1;
+ }
+ }
+
+ return 0;
+}