yin parser: CHANGE: review code and validity checks according to RFC 6020 sec 7.4 and 7.5
- type statement (built-in YANG types are not fully covered yet)
- container statements (with a generic must statement support)
diff --git a/src/tree.c b/src/tree.c
index d9f0d9d..7681689 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -252,6 +252,20 @@
ly_type_free(ctx, &tpdf->type);
}
+void ly_must_free(struct ly_ctx *ctx, struct ly_must *must)
+{
+ assert(ctx);
+ if (!must) {
+ return;
+ }
+
+ lydict_remove(ctx, must->cond);
+ lydict_remove(ctx, must->dsc);
+ lydict_remove(ctx, must->ref);
+ lydict_remove(ctx, must->eapptag);
+ lydict_remove(ctx, must->emsg);
+}
+
void ly_ident_free(struct ly_ctx *ctx, struct ly_ident *ident)
{
struct ly_ident_der *der;
@@ -323,12 +337,21 @@
int i;
/* handle only specific parts for LY_NODE_CONTAINER */
+ lydict_remove(ctx, cont->presence);
+
if (cont->tpdf_size) {
for (i = 0; i < cont->tpdf_size; i++) {
ly_tpdf_free(ctx, &cont->tpdf[i]);
}
free(cont->tpdf);
}
+
+ if (cont->must_size) {
+ for (i = 0; i < cont->must_size; i++) {
+ ly_must_free(ctx, &cont->must[i]);
+ }
+ free(cont->tpdf);
+ }
}
void ly_mnode_free(struct ly_mnode *node)