data tree REFACTOR adjust opaque node and attr members
To be more consistent with other structures.
diff --git a/src/parser_json.c b/src/parser_json.c
index 7ccf92b..96cb93d 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -541,9 +541,9 @@
LY_LIST_FOR(meta_container->child, meta_iter) {
/* convert opaq node to a attribute of the opaq node */
struct lyd_node_opaq *meta = (struct lyd_node_opaq *)meta_iter;
- ret = lyd_create_attr(node, NULL, lydctx->jsonctx->ctx, meta->name, strlen(meta->name), meta->value,
- ly_strlen(meta->value), NULL, LY_PREF_JSON, meta->hints, NULL, meta->prefix.id,
- ly_strlen(meta->prefix.id), meta->prefix.module_name, ly_strlen(meta->prefix.module_name));
+ ret = lyd_create_attr(node, NULL, lydctx->jsonctx->ctx, meta->name, strlen(meta->name), meta->prefix.id,
+ ly_strlen(meta->prefix.id), meta->prefix.module_name, ly_strlen(meta->prefix.module_name),
+ meta->value, ly_strlen(meta->value), NULL, LY_PREF_JSON, NULL, meta->hints);
LY_CHECK_GOTO(ret, cleanup);
}
@@ -774,9 +774,9 @@
lydjson_get_node_prefix(node, prefix, prefix_len, &module_name, &module_name_len);
/* attr2 is always changed to the created attribute */
- ret = lyd_create_attr(node, NULL, lydctx->jsonctx->ctx, name, name_len, lydctx->jsonctx->value,
- lydctx->jsonctx->value_len, &lydctx->jsonctx->dynamic, LY_PREF_JSON, 0, NULL, prefix, prefix_len,
- module_name, module_name_len);
+ ret = lyd_create_attr(node, NULL, lydctx->jsonctx->ctx, name, name_len, prefix, prefix_len, module_name,
+ module_name_len, lydctx->jsonctx->value, lydctx->jsonctx->value_len, &lydctx->jsonctx->dynamic,
+ LY_PREF_JSON, NULL, 0);
LY_CHECK_GOTO(ret, cleanup);
}
/* next member */
@@ -879,8 +879,8 @@
/* create node */
lydjson_get_node_prefix((struct lyd_node *)parent, prefix, prefix_len, &module_name, &module_name_len);
- ret = lyd_create_opaq(lydctx->jsonctx->ctx, name, name_len, value, value_len, &dynamic, LY_PREF_JSON, type_hint,
- NULL, prefix, prefix_len, module_name, module_name_len, node_p);
+ ret = lyd_create_opaq(lydctx->jsonctx->ctx, name, name_len, prefix, prefix_len, module_name, module_name_len, value,
+ value_len, &dynamic, LY_PREF_JSON, NULL, type_hint, node_p);
if (dynamic) {
free((char *)value);
}
@@ -1440,12 +1440,12 @@
/* now the notificationContent is expected, which will be parsed by the caller */
/* create notification envelope */
- ret = lyd_create_opaq(jsonctx->ctx, "notification", 12, "", 0, NULL, LY_PREF_JSON, LYD_NODEHINT_ENVELOPE, NULL, NULL,
- 0, "ietf-restconf", 13, envp_p);
+ ret = lyd_create_opaq(jsonctx->ctx, "notification", 12, NULL, 0, "ietf-restconf", 13, "", 0, NULL, LY_PREF_JSON,
+ NULL, LYD_NODEHINT_ENVELOPE, envp_p);
LY_CHECK_GOTO(ret, cleanup);
/* create notification envelope */
- ret = lyd_create_opaq(jsonctx->ctx, "eventTime", 9, value, value_len, &dynamic, LY_PREF_JSON, LYD_VALHINT_STRING, NULL,
- NULL, 0, "ietf-restconf", 13, &et);
+ ret = lyd_create_opaq(jsonctx->ctx, "eventTime", 9, NULL, 0, "ietf-restconf", 13, value, value_len, &dynamic,
+ LY_PREF_JSON, NULL, LYD_VALHINT_STRING, &et);
LY_CHECK_GOTO(ret, cleanup);
/* insert eventTime into notification */
lyd_insert_node(*envp_p, NULL, et);
@@ -1585,8 +1585,8 @@
LY_CHECK_GOTO(*status != LYJSON_OBJECT, cleanup);
/* create the object envelope */
- ret = lyd_create_opaq(jsonctx->ctx, object_id, strlen(object_id), "", 0, NULL, LY_PREF_JSON, LYD_NODEHINT_ENVELOPE,
- NULL, NULL, 0, module_key, ly_strlen(module_key), envp_p);
+ ret = lyd_create_opaq(jsonctx->ctx, object_id, strlen(object_id), NULL, 0, module_key, ly_strlen(module_key), "", 0,
+ NULL, LY_PREF_JSON, NULL, LYD_NODEHINT_ENVELOPE, envp_p);
LY_CHECK_GOTO(ret, cleanup);
if (parent) {
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index 75604b5..fc48cd9 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -532,8 +532,8 @@
dynamic = 1;
/* attr2 is always changed to the created attribute */
- ret = lyd_create_attr(NULL, &attr2, lybctx->ctx, name, strlen(name), value, ly_strlen(value), &dynamic, format,
- 0, val_prefix_data, prefix, ly_strlen(prefix), module_name, ly_strlen(module_name));
+ ret = lyd_create_attr(NULL, &attr2, lybctx->ctx, name, strlen(name), prefix, ly_strlen(prefix), module_name,
+ ly_strlen(module_name), value, ly_strlen(value), &dynamic, format, val_prefix_data, 0);
LY_CHECK_GOTO(ret, cleanup);
free(prefix);
@@ -774,8 +774,8 @@
dynamic = 1;
/* create node */
- ret = lyd_create_opaq(ctx, name, strlen(name), value, strlen(value), &dynamic, format, 0, val_prefix_data,
- prefix, ly_strlen(prefix), module_key, ly_strlen(module_key), &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);
LY_CHECK_GOTO(ret, cleanup);
/* process children */
diff --git a/src/parser_xml.c b/src/parser_xml.c
index 69a8354..5f3c2d7 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -183,8 +183,8 @@
&xmlctx->ns, &format, &val_prefix_data), cleanup);
/* attr2 is always changed to the created attribute */
- ret = lyd_create_attr(NULL, &attr2, xmlctx->ctx, name, name_len, xmlctx->value, xmlctx->value_len, &xmlctx->dynamic,
- format, 0, val_prefix_data, prefix, prefix_len, ns ? ns->uri : NULL, ns ? strlen(ns->uri) : 0);
+ ret = lyd_create_attr(NULL, &attr2, xmlctx->ctx, name, name_len, prefix, prefix_len, ns ? ns->uri : NULL,
+ ns ? strlen(ns->uri) : 0, xmlctx->value, xmlctx->value_len, &xmlctx->dynamic, format, val_prefix_data, 0);
LY_CHECK_GOTO(ret, cleanup);
if (!*attr) {
@@ -476,8 +476,8 @@
}
/* create node */
- ret = lyd_create_opaq(ctx, name, name_len, xmlctx->value, xmlctx->value_len, &xmlctx->dynamic, format,
- LYD_HINT_DATA, val_prefix_data, prefix, prefix_len, ns->uri, strlen(ns->uri), &node);
+ ret = lyd_create_opaq(ctx, name, name_len, prefix, prefix_len, ns->uri, strlen(ns->uri), xmlctx->value,
+ xmlctx->value_len, &xmlctx->dynamic, format, val_prefix_data, LYD_HINT_DATA, &node);
LY_CHECK_GOTO(ret, error);
/* parser next */
@@ -705,8 +705,8 @@
LY_CHECK_GOTO(ret = lyxml_ctx_next(xmlctx), cleanup);
/* create node */
- ret = lyd_create_opaq(xmlctx->ctx, name, strlen(name), "", 0, NULL, LY_PREF_XML, LYD_NODEHINT_ENVELOPE, NULL, prefix,
- prefix_len, uri, strlen(uri), envp);
+ ret = lyd_create_opaq(xmlctx->ctx, name, strlen(name), prefix, prefix_len, uri, strlen(uri), "", 0, NULL,
+ LY_PREF_XML, NULL, LYD_NODEHINT_ENVELOPE, envp);
LY_CHECK_GOTO(ret, cleanup);
/* assign atributes */
@@ -876,8 +876,8 @@
}*/
/* create node */
- ret = lyd_create_opaq(xmlctx->ctx, "eventTime", 9, xmlctx->value, xmlctx->value_len, NULL, LY_PREF_XML,
- LYD_NODEHINT_ENVELOPE, NULL, prefix, prefix_len, ns->uri, strlen(ns->uri), &et);
+ ret = lyd_create_opaq(xmlctx->ctx, "eventTime", 9, prefix, prefix_len, ns->uri, strlen(ns->uri), xmlctx->value,
+ xmlctx->value_len, NULL, LY_PREF_XML, NULL, LYD_NODEHINT_ENVELOPE, &et);
LY_CHECK_GOTO(ret, cleanup);
/* assign atributes */
diff --git a/src/tree_data.c b/src/tree_data.c
index 41d021f..4611953 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -667,9 +667,9 @@
}
LY_ERR
-lyd_create_opaq(const struct ly_ctx *ctx, const char *name, size_t name_len, const char *value, size_t value_len,
- ly_bool *dynamic, LY_PREFIX_FORMAT format, uint32_t hints, void *val_prefix_data, const char *prefix, size_t pref_len,
- const char *module_key, size_t module_key_len, struct lyd_node **node)
+lyd_create_opaq(const struct ly_ctx *ctx, const char *name, size_t name_len, const char *prefix, size_t pref_len,
+ const char *module_key, size_t module_key_len, const char *value, size_t value_len, ly_bool *dynamic,
+ LY_PREFIX_FORMAT format, void *val_prefix_data, uint32_t hints, struct lyd_node **node)
{
LY_ERR ret = LY_SUCCESS;
struct lyd_node_opaq *opaq;
@@ -681,11 +681,9 @@
}
opaq = calloc(1, sizeof *opaq);
- LY_CHECK_ERR_RET(!opaq, LOGMEM(ctx); ly_free_prefix_data(format, val_prefix_data), LY_EMEM);
+ LY_CHECK_ERR_GOTO(!opaq, LOGMEM(ctx); ret = LY_EMEM, finish);
opaq->prev = (struct lyd_node *)opaq;
- opaq->val_prefix_data = val_prefix_data;
- opaq->format = format;
LY_CHECK_GOTO(ret = lydict_insert(ctx, name, name_len, &opaq->name), finish);
if (pref_len) {
@@ -694,19 +692,22 @@
if (module_key_len) {
LY_CHECK_GOTO(ret = lydict_insert(ctx, module_key, module_key_len, &opaq->prefix.module_ns), finish);
}
-
if (dynamic && *dynamic) {
LY_CHECK_GOTO(ret = lydict_insert_zc(ctx, (char *)value, &opaq->value), finish);
*dynamic = 0;
} else {
LY_CHECK_GOTO(ret = lydict_insert(ctx, value, value_len, &opaq->value), finish);
}
+
+ opaq->format = format;
+ opaq->val_prefix_data = val_prefix_data;
opaq->hints = hints;
opaq->ctx = ctx;
finish:
if (ret) {
lyd_free_tree((struct lyd_node *)opaq);
+ ly_free_prefix_data(format, val_prefix_data);
} else {
*node = (struct lyd_node *)opaq;
}
@@ -1047,8 +1048,8 @@
value = "";
}
- LY_CHECK_RET(lyd_create_opaq(ctx, name, strlen(name), value, strlen(value), NULL, LY_PREF_JSON, 0, NULL, NULL, 0,
- module_name, strlen(module_name), &ret));
+ LY_CHECK_RET(lyd_create_opaq(ctx, name, strlen(name), NULL, 0, module_name, strlen(module_name), value,
+ strlen(value), NULL, LY_PREF_JSON, NULL, 0, &ret));
if (parent) {
lyd_insert_node(parent, NULL, ret);
}
@@ -1084,8 +1085,8 @@
val_str = "";
}
- LY_CHECK_RET(lyd_create_attr(parent, &ret, ctx, name, name_len, val_str, strlen(val_str), NULL, LY_PREF_JSON, 0, NULL,
- prefix, pref_len, module_name, module_name ? strlen(module_name) : 0));
+ LY_CHECK_RET(lyd_create_attr(parent, &ret, ctx, name, name_len, prefix, pref_len, module_name,
+ module_name ? strlen(module_name) : 0, val_str, strlen(val_str), NULL, LY_PREF_JSON, NULL, 0));
if (attr) {
*attr = ret;
@@ -1312,9 +1313,9 @@
if (!(schema->flags & LYS_KEYLESS)) {
if ((options & LYD_NEW_PATH_OPAQ) && (p[path_idx].pred_type == LY_PATH_PREDTYPE_NONE)) {
/* creating opaque list without keys */
- LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0, NULL, LY_PREF_JSON,
- LYD_NODEHINT_LIST, NULL, NULL, 0, schema->module->name, strlen(schema->module->name), &node),
- cleanup);
+ LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0,
+ schema->module->name, strlen(schema->module->name), NULL, 0, NULL, LY_PREF_JSON, NULL,
+ LYD_NODEHINT_LIST, &node), cleanup);
} else {
assert(p[path_idx].pred_type == LY_PATH_PREDTYPE_LIST);
LY_CHECK_GOTO(ret = lyd_create_list(schema, p[path_idx].predicates, &node), cleanup);
@@ -1331,9 +1332,9 @@
case LYS_LEAFLIST:
if ((options & LYD_NEW_PATH_OPAQ) && (p[path_idx].pred_type == LY_PATH_PREDTYPE_NONE)) {
/* creating opaque leaf-list without value */
- LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0, NULL, LY_PREF_JSON,
- LYD_NODEHINT_LEAFLIST, NULL, NULL, 0, schema->module->name, strlen(schema->module->name), &node),
- cleanup);
+ LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0,
+ schema->module->name, strlen(schema->module->name), NULL, 0, NULL, LY_PREF_JSON, NULL,
+ LYD_NODEHINT_LEAFLIST, &node), cleanup);
} else {
assert(p[path_idx].pred_type == LY_PATH_PREDTYPE_LEAFLIST);
LY_CHECK_GOTO(ret = lyd_create_term2(schema, &p[path_idx].predicates[0].value, &node), cleanup);
@@ -1354,8 +1355,8 @@
LY_CHECK_GOTO(ret, cleanup);
} else {
/* creating opaque leaf without value */
- LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0, NULL, LY_PREF_JSON,
- 0, NULL, NULL, 0, schema->module->name, strlen(schema->module->name), &node), cleanup);
+ LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0, schema->module->name,
+ strlen(schema->module->name), NULL, 0, NULL, LY_PREF_JSON, NULL, 0, &node), cleanup);
}
break;
case LYS_ANYDATA:
@@ -2225,8 +2226,8 @@
LY_ERR
lyd_create_attr(struct lyd_node *parent, struct lyd_attr **attr, const struct ly_ctx *ctx, const char *name, size_t name_len,
- const char *value, size_t value_len, ly_bool *dynamic, LY_PREFIX_FORMAT format, uint32_t hints,
- void *val_prefix_data, const char *prefix, size_t prefix_len, const char *module_key, size_t module_key_len)
+ const char *prefix, size_t prefix_len, const char *module_key, size_t module_key_len, const char *value,
+ size_t value_len, ly_bool *dynamic, LY_PREFIX_FORMAT format, void *val_prefix_data, uint32_t hints)
{
LY_ERR ret = LY_SUCCESS;
struct lyd_attr *at, *last;
@@ -2240,11 +2241,15 @@
at = calloc(1, sizeof *at);
LY_CHECK_ERR_RET(!at, LOGMEM(ctx); ly_free_prefix_data(format, val_prefix_data), LY_EMEM);
- at->hints = hints;
- at->format = format;
- at->val_prefix_data = val_prefix_data;
LY_CHECK_GOTO(ret = lydict_insert(ctx, name, name_len, &at->name), finish);
+ if (prefix_len) {
+ LY_CHECK_GOTO(ret = lydict_insert(ctx, prefix, prefix_len, &at->prefix.id), finish);
+ }
+ if (module_key_len) {
+ LY_CHECK_GOTO(ret = lydict_insert(ctx, module_key, module_key_len, &at->prefix.module_ns), finish);
+ }
+
if (dynamic && *dynamic) {
ret = lydict_insert_zc(ctx, (char *)value, &at->value);
LY_CHECK_GOTO(ret, finish);
@@ -2252,13 +2257,9 @@
} else {
LY_CHECK_GOTO(ret = lydict_insert(ctx, value, value_len, &at->value), finish);
}
-
- if (prefix_len) {
- LY_CHECK_GOTO(ret = lydict_insert(ctx, prefix, prefix_len, &at->prefix.id), finish);
- }
- if (module_key_len) {
- LY_CHECK_GOTO(ret = lydict_insert(ctx, module_key, module_key_len, &at->prefix.module_ns), finish);
- }
+ at->format = format;
+ at->val_prefix_data = val_prefix_data;
+ at->hints = hints;
/* insert as the last attribute */
if (parent) {
diff --git a/src/tree_data.h b/src/tree_data.h
index 81b85aa..2462c84 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -493,13 +493,12 @@
struct lyd_attr {
struct lyd_node_opaq *parent; /**< data node where the attribute is placed */
struct lyd_attr *next; /**< pointer to the next attribute */
- void *val_prefix_data; /**< format-specific prefix data (see ::ly_resolve_prefix()) */
const char *name; /**< attribute name */
- const char *value; /**< attribute value */
-
- LY_PREFIX_FORMAT format; /**< format of the attribute and any prefixes, ::LY_PREF_XML or ::LY_PREF_JSON */
- uint32_t hints; /**< additional information about from the data source, see the [hints list](@ref lydhints) */
struct ly_prefix prefix; /**< name prefix, it is stored because they are a real pain to generate properly */
+ const char *value; /**< attribute value */
+ LY_PREFIX_FORMAT format; /**< format of the attribute and any prefixes, ::LY_PREF_XML or ::LY_PREF_JSON */
+ void *val_prefix_data; /**< format-specific prefix data (see ::ly_resolve_prefix()) */
+ uint32_t hints; /**< additional information about from the data source, see the [hints list](@ref lydhints) */
};
@@ -719,13 +718,15 @@
void *priv; /**< private user data, not used by libyang */
#endif
- struct lyd_node *child; /**< pointer to the child node (NULL if there are none) */
+ struct lyd_node *child; /**< pointer to the child node (compatible with ::lyd_node_inner) */
+
const char *name; /**< node name */
- LY_PREFIX_FORMAT format; /**< format of the node and any prefixes, ::LY_PREF_XML or ::LY_PREF_JSON */
struct ly_prefix prefix; /**< name prefix */
- void *val_prefix_data; /**< format-specific prefix data (see ::ly_resolve_prefix()) */
const char *value; /**< original value */
+ LY_PREFIX_FORMAT format; /**< format of the node and any prefixes, ::LY_PREF_XML or ::LY_PREF_JSON */
+ void *val_prefix_data; /**< format-specific prefix data (see ::ly_resolve_prefix()) */
uint32_t hints; /**< additional information about from the data source, see the [hints list](@ref lydhints) */
+
const struct ly_ctx *ctx; /**< libyang context */
};
diff --git a/src/tree_data_free.c b/src/tree_data_free.c
index fa9eab8..828a152 100644
--- a/src/tree_data_free.c
+++ b/src/tree_data_free.c
@@ -145,7 +145,6 @@
lyd_free_subtree(struct lyd_node *node, ly_bool top)
{
struct lyd_node *iter, *next;
- struct lyd_node *children;
struct lyd_node_opaq *opaq = NULL;
assert(node);
@@ -154,24 +153,22 @@
opaq = (struct lyd_node_opaq *)node;
/* free the children */
- children = lyd_child(node);
- LY_LIST_FOR_SAFE(children, next, iter) {
+ LY_LIST_FOR_SAFE(lyd_child(node), next, iter) {
lyd_free_subtree(iter, 0);
}
FREE_STRING(LYD_CTX(opaq), opaq->name);
FREE_STRING(LYD_CTX(opaq), opaq->prefix.id);
FREE_STRING(LYD_CTX(opaq), opaq->prefix.module_ns);
- ly_free_prefix_data(opaq->format, opaq->val_prefix_data);
FREE_STRING(LYD_CTX(opaq), opaq->value);
+ ly_free_prefix_data(opaq->format, opaq->val_prefix_data);
} else if (node->schema->nodetype & LYD_NODE_INNER) {
/* remove children hash table in case of inner data node */
lyht_free(((struct lyd_node_inner *)node)->children_ht);
((struct lyd_node_inner *)node)->children_ht = NULL;
/* free the children */
- children = lyd_child(node);
- LY_LIST_FOR_SAFE(children, next, iter) {
+ LY_LIST_FOR_SAFE(lyd_child(node), next, iter) {
lyd_free_subtree(iter, 0);
}
} else if (node->schema->nodetype & LYD_NODE_ANY) {
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index e2e51f8..bb8e27a 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -168,23 +168,23 @@
* @param[in] ctx libyang context.
* @param[in] name Element name.
* @param[in] name_len Length of @p name, must be set correctly.
- * @param[in] value String value to be parsed.
- * @param[in] value_len Length of @p value, must be set correctly.
- * @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
- * @param[in] format Input format of @p value and @p ns.
- * @param[in] hints [Hints](@ref lydhints) from the parser regarding the node/value type.
- * @param[in] val_prefix_data Format-specific prefix data, param is spent (even in case the function fails).
* @param[in] prefix Element prefix.
* @param[in] pref_len Length of @p prefix, must be set correctly.
* @param[in] module_key Mandatory key to reference module, can be namespace or name.
* @param[in] module_key_len Length of @p module_key, must be set correctly.
+ * @param[in] value String value to be parsed.
+ * @param[in] value_len Length of @p value, must be set correctly.
+ * @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
+ * @param[in] format Input format of @p value and @p ns.
+ * @param[in] val_prefix_data Format-specific prefix data, param is spent (even in case the function fails).
+ * @param[in] hints [Hints](@ref lydhints) from the parser regarding the node/value type.
* @param[out] node Created node.
* @return LY_SUCCESS on success.
* @return LY_ERR value if an error occurred.
*/
-LY_ERR lyd_create_opaq(const struct ly_ctx *ctx, const char *name, size_t name_len, const char *value, size_t value_len,
- ly_bool *dynamic, LY_PREFIX_FORMAT format, uint32_t hints, void *val_prefix_data, const char *prefix,
- size_t pref_len, const char *module_key, size_t module_key_len, struct lyd_node **node);
+LY_ERR lyd_create_opaq(const struct ly_ctx *ctx, const char *name, size_t name_len, const char *prefix, size_t pref_len,
+ const char *module_key, size_t module_key_len, const char *value, size_t value_len, ly_bool *dynamic,
+ LY_PREFIX_FORMAT format, void *val_prefix_data, uint32_t hints, struct lyd_node **node);
/**
* @brief Check the existence and create any non-existing implicit siblings, recursively for the created nodes.
@@ -271,22 +271,22 @@
* @param[in] ctx libyang context.
* @param[in] name Attribute name.
* @param[in] name_len Length of @p name, must be set correctly.
- * @param[in] value String value to be parsed.
- * @param[in] value_len Length of @p value, must be set correctly.
- * @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
- * @param[in] format Input format of @p value and @p ns.
- * @param[in] hints [Hints](@ref lydhints) from the parser regarding the node/value type.
- * @param[in] val_prefix_data Format-specific prefix data, param is spent (even in case the function fails).
* @param[in] prefix Attribute prefix.
* @param[in] prefix_len Attribute prefix length.
* @param[in] module_key Mandatory key to reference module, can be namespace or name.
* @param[in] module_key_len Length of @p module_key, must be set correctly.
+ * @param[in] value String value to be parsed.
+ * @param[in] value_len Length of @p value, must be set correctly.
+ * @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
+ * @param[in] format Input format of @p value and @p ns.
+ * @param[in] val_prefix_data Format-specific prefix data, param is spent (even in case the function fails).
+ * @param[in] hints [Hints](@ref lydhints) from the parser regarding the node/value type.
* @return LY_SUCCESS on success,
* @return LY_ERR value on error.
*/
LY_ERR lyd_create_attr(struct lyd_node *parent, struct lyd_attr **attr, const struct ly_ctx *ctx, const char *name,
- size_t name_len, const char *value, size_t value_len, ly_bool *dynamic, LY_PREFIX_FORMAT format, uint32_t hints,
- void *val_prefix_data, const char *prefix, size_t prefix_len, const char *module_key, size_t module_key_len);
+ size_t name_len, const char *prefix, size_t prefix_len, const char *module_key, size_t module_key_len,
+ const char *value, size_t value_len, ly_bool *dynamic, LY_PREFIX_FORMAT format, void *val_prefix_data, uint32_t hints);
/**
* @brief Store and canonize the given @p value into @p val according to the schema node type rules.
diff --git a/tests/utests/data/test_new.c b/tests/utests/data/test_new.c
index 82620ad..c1fec03 100644
--- a/tests/utests/data/test_new.c
+++ b/tests/utests/data/test_new.c
@@ -204,15 +204,15 @@
assert_null(root->schema);
opq = (struct lyd_node_opaq *)root;
assert_string_equal(opq->name, "node1");
- assert_string_equal(opq->value, "");
assert_string_equal(opq->prefix.module_name, "my-module");
+ assert_string_equal(opq->value, "");
assert_int_equal(lyd_new_opaq(root, NULL, "node2", "value", "my-module2", &node), LY_SUCCESS);
assert_null(node->schema);
opq = (struct lyd_node_opaq *)node;
assert_string_equal(opq->name, "node2");
- assert_string_equal(opq->value, "value");
assert_string_equal(opq->prefix.module_name, "my-module2");
+ assert_string_equal(opq->value, "value");
assert_ptr_equal(opq->parent, root);
lyd_free_tree(root);