libyang REFACTOR separate macros to edit sized arrays and linked list
Keep the macros in a standalone header to allow making this header
public for plugins API in future without affecting the rest of internal
data in common.h
diff --git a/src/plugins_exts_yangdata.c b/src/plugins_exts_yangdata.c
index ec4e8fc..dd14e43 100644
--- a/src/plugins_exts_yangdata.c
+++ b/src/plugins_exts_yangdata.c
@@ -14,9 +14,10 @@
#include <stdlib.h>
-#include "common.h"
#include "plugins_exts.h"
#include "schema_compile.h"
+
+#include "tree_edit.h"
#include "tree_schema.h"
/**
@@ -74,7 +75,7 @@
* To let the compilation accept different statements possibly leading to the container top-level node, there are 3
* allowed substatements pointing to a single storage. But when compiled, the substaments list is compressed just to
* a single item providing the schema tree. */
- LY_ARRAY_CREATE_RET(cctx->ctx, c_ext->substmts, 3, LY_EMEM);
+ LY_ARRAY_CREATE_GOTO(cctx->ctx, c_ext->substmts, 3, ret, emem);
LY_ARRAY_INCREMENT(c_ext->substmts);
c_ext->substmts[0].stmt = LY_STMT_CONTAINER;
c_ext->substmts[0].cardinality = LY_STMT_CARD_OPT;
@@ -143,6 +144,10 @@
}
return LY_SUCCESS;
+
+emem:
+ lyext_log(c_ext, LY_LLERR, LY_EMEM, cctx->path, "Memory allocation failed (%s()).", __func__);
+ return LY_EMEM;
}
/**