extensions FEATURE allow inheritance of the extension instances
sometimes (mainly in case of flag extensions) it may be useful to
inherit the extension instance into its children. Such an inherited
copy of the extension is not printed as part of the module, but it
is available when working with the schema tree to get know that
the (extension) flag is connected (since inherited from a parent)
with a schema node.
The feature is used in the NACM extensions implementation since it
simplifies checking for NACM extension presence.
diff --git a/src/tree_schema.c b/src/tree_schema.c
index f8463f8..248aa44 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -333,19 +333,11 @@
continue;
}
- /* common part */
- lys_extension_instances_free(ctx, e[i]->ext, e[i]->ext_size);
- lydict_remove(ctx, e[i]->arg_value);
-
- /* specific part according to the extension type */
- switch(lys_ext_instance_type(e[i])) {
- case LYEXT_FLAG:
- /* flag instance - nothing special needed */
- break;
- case LYEXT_ERR:
- /* should not appear */
- LOGINT;
- break;
+ if (e[i]->flags & LYEXT_OPT_INHERIT) {
+ /* no free, this is just a shadow copy of the original extension instance */
+ } else {
+ lys_extension_instances_free(ctx, e[i]->ext, e[i]->ext_size);
+ lydict_remove(ctx, e[i]->arg_value);
}
free(e[i]);
}