extension instances CHANGE access to the extension instance's substatements
Provide libyang a transparent access to the substatements of a specific
extension instances for various generic processing.
The patch introduces lysc_ext_substmt() to simplify work with the newly
added lysc_ext_instance.substmts sized array providing the extension
instance's substatements.
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index 071de57..8bcfb5a 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -987,9 +987,11 @@
}
API void
-lysc_extension_instance_free(struct ly_ctx *ctx, struct lysc_ext_substmt *substmts)
+lysc_extension_instance_substatements_free(struct ly_ctx *ctx, struct lysc_ext_substmt *substmts)
{
- for (LY_ARRAY_COUNT_TYPE u = 0; substmts[u].stmt; ++u) {
+ LY_ARRAY_COUNT_TYPE u;
+
+ LY_ARRAY_FOR(substmts, u) {
if (!substmts[u].storage) {
continue;
}
@@ -1012,6 +1014,8 @@
FREE_ARRAY(ctx, types, lysc_type2_free);
}
break;
+ case LY_STMT_DESCRIPTION:
+ case LY_STMT_REFERENCE:
case LY_STMT_UNITS:
if (substmts[u].cardinality < LY_STMT_CARD_SOME) {
/* single item */
@@ -1054,6 +1058,8 @@
LOGINT(ctx);
}
}
+
+ LY_ARRAY_FREE(substmts);
}
void