summaryrefslogtreecommitdiffstats
path: root/src/parser_lyb.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:23:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:23:18 +0000
commit41b1317ec41265120f7355c60ecd5d103f2257e4 (patch)
tree4adcd743b92041075b7764abf6f140b7eb4f4332 /src/parser_lyb.c
parentAdding debian version 2.1.30-2.1. (diff)
downloadlibyang2-41b1317ec41265120f7355c60ecd5d103f2257e4.tar.xz
libyang2-41b1317ec41265120f7355c60ecd5d103f2257e4.zip
Merging upstream version 2.1.148.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/parser_lyb.c')
-rw-r--r--src/parser_lyb.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index f898085..788be94 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -49,11 +49,15 @@ lylyb_ctx_free(struct lylyb_ctx *ctx)
{
LY_ARRAY_COUNT_TYPE u;
+ if (!ctx) {
+ return;
+ }
+
LY_ARRAY_FREE(ctx->siblings);
LY_ARRAY_FREE(ctx->models);
LY_ARRAY_FOR(ctx->sib_hts, u) {
- lyht_free(ctx->sib_hts[u].ht);
+ lyht_free(ctx->sib_hts[u].ht, NULL);
}
LY_ARRAY_FREE(ctx->sib_hts);
@@ -65,6 +69,10 @@ lyd_lyb_ctx_free(struct lyd_ctx *lydctx)
{
struct lyd_lyb_ctx *ctx = (struct lyd_lyb_ctx *)lydctx;
+ if (!lydctx) {
+ return;
+ }
+
lyd_ctx_free(lydctx);
lylyb_ctx_free(ctx->lybctx);
free(ctx);
@@ -1082,7 +1090,7 @@ lyb_validate_node_inner(struct lyd_lyb_ctx *lybctx, const struct lysc_node *snod
if (!(lybctx->parse_opts & LYD_PARSE_ONLY)) {
/* new node validation, autodelete CANNOT occur, all nodes are new */
- ret = lyd_validate_new(lyd_node_child_p(node), snode, NULL, NULL);
+ ret = lyd_validate_new(lyd_node_child_p(node), snode, NULL, 0, NULL);
LY_CHECK_RET(ret);
/* add any missing default children */
@@ -1160,9 +1168,12 @@ lyb_parse_node_opaq(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, struct
/* create node */
ret = lyd_create_opaq(ctx, name, strlen(name), prefix, ly_strlen(prefix), module_key, ly_strlen(module_key),
- value, strlen(value), &dynamic, format, val_prefix_data, 0, &node);
+ value, strlen(value), &dynamic, format, val_prefix_data, LYD_HINT_DATA, &node);
LY_CHECK_GOTO(ret, cleanup);
+ assert(node);
+ LOG_LOCSET(NULL, node, NULL, NULL);
+
/* process children */
ret = lyb_parse_siblings(lybctx, node, NULL, NULL);
LY_CHECK_GOTO(ret, cleanup);
@@ -1170,8 +1181,12 @@ lyb_parse_node_opaq(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, struct
/* register parsed opaq node */
lyb_finish_opaq(lybctx, parent, flags, &attr, &node, first_p, parsed);
assert(!attr && !node);
+ LOG_LOCBACK(0, 1, 0, 0);
cleanup:
+ if (node) {
+ LOG_LOCBACK(0, 1, 0, 0);
+ }
free(prefix);
free(module_key);
free(name);
@@ -1257,9 +1272,13 @@ lyb_parse_node_any(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, const st
goto error;
}
+ assert(node);
+ LOG_LOCSET(NULL, node, NULL, NULL);
+
/* register parsed anydata node */
lyb_finish_node(lybctx, parent, flags, &meta, &node, first_p, parsed);
+ LOG_LOCBACK(0, 1, 0, 0);
return LY_SUCCESS;
error:
@@ -1296,6 +1315,9 @@ lyb_parse_node_inner(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, const
ret = lyd_create_inner(snode, &node);
LY_CHECK_GOTO(ret, error);
+ assert(node);
+ LOG_LOCSET(NULL, node, NULL, NULL);
+
/* process children */
ret = lyb_parse_siblings(lybctx, node, NULL, NULL);
LY_CHECK_GOTO(ret, error);
@@ -1312,9 +1334,13 @@ lyb_parse_node_inner(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, const
/* register parsed node */
lyb_finish_node(lybctx, parent, flags, &meta, &node, first_p, parsed);
+ LOG_LOCBACK(0, 1, 0, 0);
return LY_SUCCESS;
error:
+ if (node) {
+ LOG_LOCBACK(0, 1, 0, 0);
+ }
lyd_free_meta_siblings(meta);
lyd_free_tree(node);
return ret;
@@ -1347,8 +1373,12 @@ lyb_parse_node_leaf(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, const s
ret = lyb_create_term(lybctx, snode, &node);
LY_CHECK_GOTO(ret, error);
+ assert(node);
+ LOG_LOCSET(NULL, node, NULL, NULL);
+
lyb_finish_node(lybctx, parent, flags, &meta, &node, first_p, parsed);
+ LOG_LOCBACK(0, 1, 0, 0);
return LY_SUCCESS;
error:
@@ -1408,6 +1438,7 @@ lyb_parse_node_list(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, const s
struct lyd_node *node = NULL;
struct lyd_meta *meta = NULL;
uint32_t flags;
+ ly_bool log_node = 0;
/* register a new sibling */
ret = lyb_read_start_siblings(lybctx->lybctx);
@@ -1422,6 +1453,10 @@ lyb_parse_node_list(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, const s
ret = lyd_create_inner(snode, &node);
LY_CHECK_GOTO(ret, error);
+ assert(node);
+ LOG_LOCSET(NULL, node, NULL, NULL);
+ log_node = 1;
+
/* process children */
ret = lyb_parse_siblings(lybctx, node, NULL, NULL);
LY_CHECK_GOTO(ret, error);
@@ -1437,6 +1472,9 @@ lyb_parse_node_list(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, const s
/* register parsed list node */
lyb_finish_node(lybctx, parent, flags, &meta, &node, first_p, parsed);
+
+ LOG_LOCBACK(0, 1, 0, 0);
+ log_node = 0;
}
/* end the sibling */
@@ -1446,6 +1484,9 @@ lyb_parse_node_list(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, const s
return LY_SUCCESS;
error:
+ if (log_node) {
+ LOG_LOCBACK(0, 1, 0, 0);
+ }
lyd_free_meta_siblings(meta);
lyd_free_tree(node);
return ret;
@@ -1484,7 +1525,7 @@ lyb_parse_node(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, struct lyd_n
case LYB_NODE_CHILD:
case LYB_NODE_OPAQ:
/* read hash, find the schema node starting from parent schema, if any */
- LY_CHECK_GOTO(ret = lyb_parse_schema_hash(lybctx, parent ? parent->schema : NULL, NULL, &snode), cleanup);
+ LY_CHECK_GOTO(ret = lyb_parse_schema_hash(lybctx, lyd_parser_node_schema(parent), NULL, &snode), cleanup);
break;
case LYB_NODE_EXT:
/* ext, read module name */