extension FEATURE parsed tree in lysp_ext_instance
A pointer to the parsed tree is now available in the lysp_ext_instance
structure. Now it is not necessary to temporarily create a parsed tree
in the lys_compile_extension_instance function. The callback function
lyplg_ext_compile_clb had to lose the const qualifier for the
lysp_ext_instance parameter.
diff --git a/src/schema_compile.c b/src/schema_compile.c
index 51937e0..bb6ab79 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -574,12 +574,26 @@
case LY_STMT_NOTIFICATION:
case LY_STMT_RPC:
case LY_STMT_USES:
- r = lysp_stmt_parse(ctx, stmt, &parsed, NULL);
- LY_CHECK_ERR_GOTO(r, ret = r, cleanup);
+ if (!ext_p->parsed) {
+ struct lysp_ext_instance *unconst_ext_p;
+ r = lysp_stmt_parse(ctx, stmt, &parsed, NULL);
+ LY_CHECK_ERR_GOTO(r, ret = r, cleanup);
+ unconst_ext_p = (struct lysp_ext_instance *)ext_p;
+ unconst_ext_p->parsed = parsed;
+ } else {
+ struct lysp_node *node, *last_node;
+ /* get last parsed node */
+ LY_LIST_FOR(ext_p->parsed, node) {
+ last_node = node;
+ }
+ /* create and link sibling */
+ r = lysp_stmt_parse(ctx, stmt, &parsed, NULL);
+ LY_CHECK_ERR_GOTO(r, ret = r, cleanup);
+ last_node->next = parsed;
+ }
/* set storage as an alternative document root in the compile context */
r = lys_compile_node(ctx, parsed, NULL, 0, NULL);
- lysp_node_free(ctx->ctx, parsed);
LY_CHECK_ERR_GOTO(r, ret = r, cleanup);
break;
case LY_STMT_DESCRIPTION: