dict FEATURE detect errors in lydict_remove
Redundant macro FREE_STRING removed.
diff --git a/src/common.h b/src/common.h
index a5fcd5d..e1e8319 100644
--- a/src/common.h
+++ b/src/common.h
@@ -349,8 +349,6 @@
} \
DYNAMIC = 0
-#define FREE_STRING(CTX, STRING) if (STRING) {lydict_remove(CTX, STRING);}
-
/**
* @brief Wrapper for realloc() call. The only difference is that if it fails to
* allocate the requested memory, the original memory is freed as well.
diff --git a/src/dict.h b/src/dict.h
index 68e1081..7874813 100644
--- a/src/dict.h
+++ b/src/dict.h
@@ -107,8 +107,11 @@
* @param[in] value String to be freed. Note, that not only the string itself
* must match the stored value, but also the address is being compared and the
* counter is decremented only if it matches. If NULL, function does nothing.
+ * @return LY_SUCCESS if the value was found and removed (or refcount decreased).
+ * @return LY_ENOTFOUND if the value was not found.
+ * @return LY_ERR on other errors.
*/
-void lydict_remove(const struct ly_ctx *ctx, const char *value);
+LY_ERR lydict_remove(const struct ly_ctx *ctx, const char *value);
/** @} dict */
diff --git a/src/hash_table.c b/src/hash_table.c
index e181a11..0564eb9 100644
--- a/src/hash_table.c
+++ b/src/hash_table.c
@@ -156,19 +156,21 @@
return 0;
}
-API void
+API LY_ERR
lydict_remove(const struct ly_ctx *ctx, const char *value)
{
- LY_ERR ret;
+ LY_ERR ret = LY_SUCCESS;
size_t len;
uint32_t hash;
struct dict_rec rec, *match = NULL;
char *val_p;
if (!value) {
- return;
+ return LY_SUCCESS;
}
+ LOGDBG(LY_LDGDICT, "removing \"%s\"", value);
+
len = strlen(value);
hash = dict_hash(value, len);
@@ -198,10 +200,15 @@
free(val_p);
LY_CHECK_ERR_GOTO(ret, LOGINT(ctx), finish);
}
+ } else if (ret == LY_ENOTFOUND) {
+ LOGERR(ctx, LY_ENOTFOUND, "Value \"%s\" was not found in the dictionary.", value);
+ } else {
+ LOGINT(ctx);
}
finish:
pthread_mutex_unlock((pthread_mutex_t *)&ctx->dict.lock);
+ return ret;
}
LY_ERR
@@ -211,6 +218,8 @@
struct dict_rec *match = NULL, rec;
uint32_t hash;
+ LOGDBG(LY_LDGDICT, "inserting \"%.*s\"", len, value);
+
hash = dict_hash(value, len);
/* set len as data for compare callback */
lyht_set_cb_data(ctx->dict.hash_tab, (void *)&len);
@@ -218,7 +227,6 @@
rec.value = value;
rec.refcount = 1;
- LOGDBG(LY_LDGDICT, "inserting \"%s\"", rec.value);
ret = lyht_insert_with_resize_cb(ctx->dict.hash_tab, (void *)&rec, hash, lydict_resize_val_eq, (void **)&match);
if (ret == LY_EEXIST) {
match->refcount++;
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 1329799..7255c4c 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -638,7 +638,7 @@
saved_value = malloc(len + 2);
LY_CHECK_ERR_RET(!saved_value, LOGMEM(ctx->xmlctx->ctx), LY_EMEM);
memmove(saved_value + 1, real_value, len);
- FREE_STRING(ctx->xmlctx->ctx, real_value);
+ lydict_remove(ctx->xmlctx->ctx, real_value);
saved_value[0] = LYSP_RESTR_PATTERN_ACK;
saved_value[len + 1] = '\0';
LY_CHECK_RET(lydict_insert_zc(ctx->xmlctx->ctx, saved_value, &restr->arg.str));
@@ -676,7 +676,7 @@
if ((temp_val[0] == '\0') || (temp_val[0] == '0') || !isdigit(temp_val[0])) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "fraction-digits");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
@@ -684,15 +684,15 @@
num = strtoul(temp_val, &ptr, LY_BASE_DEC);
if (*ptr != '\0') {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "fraction-digits");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
if ((errno == ERANGE) || (num > LY_TYPE_DEC64_FD_MAX)) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "fraction-digits");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
type->fraction_digits = num;
type->flags |= LYS_SET_FRDIGITS;
struct yin_subelement subelems[] = {
@@ -873,10 +873,10 @@
} else if (strcmp(temp_val, "false") != 0) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_val, "value",
"require-instance", "true", "false");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_REQUIRE_INSTANCE, NULL, &type->exts);
}
@@ -905,7 +905,7 @@
if (strcmp(temp_val, "invert-match") != 0) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS1, temp_val, "value",
"modifier", "invert-match");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
lydict_remove(ctx->xmlctx->ctx, temp_val);
@@ -1106,7 +1106,7 @@
} else {
enm->value = unum;
}
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
/* parse subelements */
struct yin_subelement subelems[] = {
@@ -1116,7 +1116,7 @@
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), kw, NULL, &enm->exts);
error:
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
@@ -1280,7 +1280,7 @@
LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_MAX_ELEMENTS));
if (!temp_val || (temp_val[0] == '\0') || (temp_val[0] == '0') || ((temp_val[0] != 'u') && !isdigit(temp_val[0]))) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "max-elements");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
@@ -1289,17 +1289,17 @@
num = strtoul(temp_val, &ptr, LY_BASE_DEC);
if (*ptr != '\0') {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "max-elements");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
if ((errno == ERANGE) || (num > UINT32_MAX)) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_OOB_YIN, temp_val, "value", "max-elements");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
*max = num;
}
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_MAX_ELEMENTS, NULL, exts);
}
@@ -1329,7 +1329,7 @@
if (!temp_val || (temp_val[0] == '\0') || ((temp_val[0] == '0') && (temp_val[1] != '\0'))) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "min-elements");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
@@ -1337,16 +1337,16 @@
num = strtoul(temp_val, &ptr, LY_BASE_DEC);
if (ptr[0] != 0) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "min-elements");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
if ((errno == ERANGE) || (num > UINT32_MAX)) {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_OOB_YIN, temp_val, "value", "min-elements");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
*min = num;
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_MIN_ELEMENTS, NULL, exts);
}
@@ -1422,10 +1422,10 @@
} else {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_val, "value",
"ordered-by", "system", "user");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_ORDERED_BY, NULL, exts);
}
@@ -1707,11 +1707,11 @@
LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_DATE, &temp_date, Y_STR_ARG, LY_STMT_REVISION));
/* check value */
if (lysp_check_date((struct lys_parser_ctx *)ctx, temp_date, strlen(temp_date), "revision")) {
- FREE_STRING(ctx->xmlctx->ctx, temp_date);
+ lydict_remove(ctx->xmlctx->ctx, temp_date);
return LY_EVALID;
}
memcpy(rev->date, temp_date, LY_REV_SIZE);
- FREE_STRING(ctx->xmlctx->ctx, temp_date);
+ lydict_remove(ctx->xmlctx->ctx, temp_date);
/* parse content */
struct yin_subelement subelems[] = {
@@ -1781,10 +1781,10 @@
LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_DATE, &temp_rev, Y_STR_ARG, LY_STMT_REVISION_DATE));
LY_CHECK_ERR_RET(lysp_check_date((struct lys_parser_ctx *)ctx, temp_rev, strlen(temp_rev), "revision-date") != LY_SUCCESS,
- FREE_STRING(ctx->xmlctx->ctx, temp_rev), LY_EVALID);
+ lydict_remove(ctx->xmlctx->ctx, temp_rev), LY_EVALID);
strcpy(rev, temp_rev);
- FREE_STRING(ctx->xmlctx->ctx, temp_rev);
+ lydict_remove(ctx->xmlctx->ctx, temp_rev);
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_REVISION_DATE, NULL, exts);
}
@@ -1815,10 +1815,10 @@
} else {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_val, "value", "config",
"true", "false");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_CONFIG, NULL, exts);
}
@@ -1849,10 +1849,10 @@
} else {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_version, "value",
"yang-version", "1", "1.1");
- FREE_STRING(ctx->xmlctx->ctx, temp_version);
+ lydict_remove(ctx->xmlctx->ctx, temp_version);
return LY_EVALID;
}
- FREE_STRING(ctx->xmlctx->ctx, temp_version);
+ lydict_remove(ctx->xmlctx->ctx, temp_version);
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_YANG_VERSION, NULL, exts);
}
@@ -1917,10 +1917,10 @@
} else {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_val, "value",
"mandatory", "true", "false");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_MANDATORY, NULL, exts);
}
@@ -1953,10 +1953,10 @@
} else {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS3, value, "value",
"status", "current", "deprecated", "obsolete");
- FREE_STRING(ctx->xmlctx->ctx, value);
+ lydict_remove(ctx->xmlctx->ctx, value);
return LY_EVALID;
}
- FREE_STRING(ctx->xmlctx->ctx, value);
+ lydict_remove(ctx->xmlctx->ctx, value);
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_STATUS, NULL, exts);
}
@@ -2019,10 +2019,10 @@
} else {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_val, "value",
"yin-element", "true", "false");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return yin_parse_content(ctx, subelems, ly_sizeofarray(subelems), LY_STMT_YIN_ELEMENT, NULL, exts);
}
@@ -2652,10 +2652,10 @@
} else {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS4, temp_val, "value", "deviate",
"not-supported", "add", "replace", "delete");
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
return LY_EVALID;
}
- FREE_STRING(ctx->xmlctx->ctx, temp_val);
+ lydict_remove(ctx->xmlctx->ctx, temp_val);
if (dev_mod == LYS_DEV_NOT_SUPPORTED) {
d = calloc(1, sizeof *d);
diff --git a/src/printer_xml.c b/src/printer_xml.c
index 086c62b..bd27142 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -558,7 +558,7 @@
/* remove all added namespaces */
while (ns_count < ctx->ns.count) {
- FREE_STRING(ctx->ctx, ctx->prefix.objs[ctx->prefix.count - 1]);
+ lydict_remove(ctx->ctx, ctx->prefix.objs[ctx->prefix.count - 1]);
ly_set_rm_index(&ctx->prefix, ctx->prefix.count - 1, NULL);
ly_set_rm_index(&ctx->ns, ctx->ns.count - 1, NULL);
}
diff --git a/src/schema_compile_amend.c b/src/schema_compile_amend.c
index 91f646f..dfd5a55 100644
--- a/src/schema_compile_amend.c
+++ b/src/schema_compile_amend.c
@@ -656,7 +656,7 @@
case LYS_LEAF:
AMEND_CHECK_CARDINALITY(rfn->dflts, 1, "refine", "default");
- FREE_STRING(ctx->ctx, ((struct lysp_node_leaf *)target)->dflt.str);
+ lydict_remove(ctx->ctx, ((struct lysp_node_leaf *)target)->dflt.str);
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &((struct lysp_node_leaf *)target)->dflt, &rfn->dflts[0]), cleanup);
break;
case LYS_LEAFLIST:
@@ -677,7 +677,7 @@
case LYS_CHOICE:
AMEND_CHECK_CARDINALITY(rfn->dflts, 1, "refine", "default");
- FREE_STRING(ctx->ctx, ((struct lysp_node_choice *)target)->dflt.str);
+ lydict_remove(ctx->ctx, ((struct lysp_node_choice *)target)->dflt.str);
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &((struct lysp_node_choice *)target)->dflt, &rfn->dflts[0]), cleanup);
break;
default:
@@ -687,13 +687,13 @@
/* description */
if (rfn->dsc) {
- FREE_STRING(ctx->ctx, target->dsc);
+ lydict_remove(ctx->ctx, target->dsc);
DUP_STRING_GOTO(ctx->ctx, rfn->dsc, target->dsc, ret, cleanup);
}
/* reference */
if (rfn->ref) {
- FREE_STRING(ctx->ctx, target->ref);
+ lydict_remove(ctx->ctx, target->ref);
DUP_STRING_GOTO(ctx->ctx, rfn->ref, target->ref, ret, cleanup);
}
@@ -733,7 +733,7 @@
AMEND_WRONG_NODETYPE("refine", "replace", "presence");
}
- FREE_STRING(ctx->ctx, ((struct lysp_node_container *)target)->presence);
+ lydict_remove(ctx->ctx, ((struct lysp_node_container *)target)->presence);
DUP_STRING_GOTO(ctx->ctx, rfn->presence, ((struct lysp_node_container *)target)->presence, ret, cleanup);
}
@@ -1082,7 +1082,7 @@
}
DEV_CHECK_PRESENCE_VALUE(struct lysp_node_leaf *, units, "deleting", "units", d->units);
- FREE_STRING(ctx->ctx, ((struct lysp_node_leaf *)target)->units);
+ lydict_remove(ctx->ctx, ((struct lysp_node_leaf *)target)->units);
((struct lysp_node_leaf *)target)->units = NULL;
}
@@ -1116,7 +1116,7 @@
AMEND_CHECK_CARDINALITY(d->dflts, 1, "deviation", "default");
DEV_CHECK_PRESENCE_VALUE(struct lysp_node_leaf *, dflt.str, "deleting", "default", d->dflts[0].str);
- FREE_STRING(ctx->ctx, ((struct lysp_node_leaf *)target)->dflt.str);
+ lydict_remove(ctx->ctx, ((struct lysp_node_leaf *)target)->dflt.str);
((struct lysp_node_leaf *)target)->dflt.str = NULL;
break;
case LYS_LEAFLIST:
@@ -1127,7 +1127,7 @@
AMEND_CHECK_CARDINALITY(d->dflts, 1, "deviation", "default");
DEV_CHECK_PRESENCE_VALUE(struct lysp_node_choice *, dflt.str, "deleting", "default", d->dflts[0].str);
- FREE_STRING(ctx->ctx, ((struct lysp_node_choice *)target)->dflt.str);
+ lydict_remove(ctx->ctx, ((struct lysp_node_choice *)target)->dflt.str);
((struct lysp_node_choice *)target)->dflt.str = NULL;
break;
default:
@@ -1185,7 +1185,7 @@
}
DEV_CHECK_PRESENCE(struct lysp_node_leaf *, units, "replacing", "units", d->units);
- FREE_STRING(ctx->ctx, ((struct lysp_node_leaf *)target)->units);
+ lydict_remove(ctx->ctx, ((struct lysp_node_leaf *)target)->units);
DUP_STRING_GOTO(ctx->ctx, d->units, ((struct lysp_node_leaf *)target)->units, ret, cleanup);
}
@@ -1195,13 +1195,13 @@
case LYS_LEAF:
DEV_CHECK_PRESENCE(struct lysp_node_leaf *, dflt.str, "replacing", "default", d->dflt.str);
- FREE_STRING(ctx->ctx, ((struct lysp_node_leaf *)target)->dflt.str);
+ lydict_remove(ctx->ctx, ((struct lysp_node_leaf *)target)->dflt.str);
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &((struct lysp_node_leaf *)target)->dflt, &d->dflt), cleanup);
break;
case LYS_CHOICE:
DEV_CHECK_PRESENCE(struct lysp_node_choice *, dflt.str, "replacing", "default", d->dflt);
- FREE_STRING(ctx->ctx, ((struct lysp_node_choice *)target)->dflt.str);
+ lydict_remove(ctx->ctx, ((struct lysp_node_choice *)target)->dflt.str);
LY_CHECK_GOTO(ret = lysp_qname_dup(ctx->ctx, &((struct lysp_node_choice *)target)->dflt, &d->dflt), cleanup);
break;
default:
diff --git a/src/tree_data_free.c b/src/tree_data_free.c
index cb5a6c5..ffeb9d5 100644
--- a/src/tree_data_free.c
+++ b/src/tree_data_free.c
@@ -60,7 +60,7 @@
meta = iter;
iter = iter->next;
- FREE_STRING(meta->annotation->module->ctx, meta->name);
+ lydict_remove(meta->annotation->module->ctx, meta->name);
meta->value.realtype->plugin->free(meta->annotation->module->ctx, &meta->value);
free(meta);
}
@@ -116,10 +116,10 @@
iter = iter->next;
ly_free_prefix_data(attr->format, attr->val_prefix_data);
- FREE_STRING(ctx, attr->name.name);
- FREE_STRING(ctx, attr->name.prefix);
- FREE_STRING(ctx, attr->name.module_ns);
- FREE_STRING(ctx, attr->value);
+ lydict_remove(ctx, attr->name.name);
+ lydict_remove(ctx, attr->name.prefix);
+ lydict_remove(ctx, attr->name.module_ns);
+ lydict_remove(ctx, attr->value);
free(attr);
}
}
@@ -157,10 +157,10 @@
lyd_free_subtree(iter, 0);
}
- FREE_STRING(LYD_CTX(opaq), opaq->name.name);
- FREE_STRING(LYD_CTX(opaq), opaq->name.prefix);
- FREE_STRING(LYD_CTX(opaq), opaq->name.module_ns);
- FREE_STRING(LYD_CTX(opaq), opaq->value);
+ lydict_remove(LYD_CTX(opaq), opaq->name.name);
+ lydict_remove(LYD_CTX(opaq), opaq->name.prefix);
+ lydict_remove(LYD_CTX(opaq), opaq->name.module_ns);
+ lydict_remove(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 */
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index b62146f..d0a0ce7 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -266,7 +266,7 @@
case LYD_ANYDATA_STRING:
case LYD_ANYDATA_XML:
case LYD_ANYDATA_JSON:
- FREE_STRING(LYD_CTX(trg), t->value.str);
+ lydict_remove(LYD_CTX(trg), t->value.str);
break;
case LYD_ANYDATA_LYB:
free(t->value.mem);
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index 78eb75e..626c2d4 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -35,8 +35,8 @@
{
struct lysp_stmt *child, *next;
- FREE_STRING(ctx, stmt->stmt);
- FREE_STRING(ctx, stmt->arg);
+ lydict_remove(ctx, stmt->stmt);
+ lydict_remove(ctx, stmt->arg);
LY_LIST_FOR_SAFE(stmt->child, next, child) {
lysp_stmt_free(ctx, child);
@@ -50,8 +50,8 @@
{
struct lysp_stmt *stmt, *next;
- FREE_STRING(ctx, ext->name);
- FREE_STRING(ctx, ext->argument);
+ lydict_remove(ctx, ext->name);
+ lydict_remove(ctx, ext->argument);
LY_LIST_FOR_SAFE(ext->child, next, stmt) {
lysp_stmt_free(ctx, stmt);
@@ -62,10 +62,10 @@
lysp_import_free(struct ly_ctx *ctx, struct lysp_import *import)
{
/* imported module is freed directly from the context's list */
- FREE_STRING(ctx, import->name);
- FREE_STRING(ctx, import->prefix);
- FREE_STRING(ctx, import->dsc);
- FREE_STRING(ctx, import->ref);
+ lydict_remove(ctx, import->name);
+ lydict_remove(ctx, import->prefix);
+ lydict_remove(ctx, import->dsc);
+ lydict_remove(ctx, import->ref);
FREE_ARRAY(ctx, import->exts, lysp_ext_instance_free);
}
@@ -87,9 +87,9 @@
if (main_module && include->submodule) {
lysp_module_free((struct lysp_module *)include->submodule);
}
- FREE_STRING(ctx, include->name);
- FREE_STRING(ctx, include->dsc);
- FREE_STRING(ctx, include->ref);
+ lydict_remove(ctx, include->name);
+ lydict_remove(ctx, include->dsc);
+ lydict_remove(ctx, include->ref);
FREE_ARRAY(ctx, include->exts, lysp_ext_instance_free);
}
@@ -108,18 +108,18 @@
void
lysp_revision_free(struct ly_ctx *ctx, struct lysp_revision *rev)
{
- FREE_STRING(ctx, rev->dsc);
- FREE_STRING(ctx, rev->ref);
+ lydict_remove(ctx, rev->dsc);
+ lydict_remove(ctx, rev->ref);
FREE_ARRAY(ctx, rev->exts, lysp_ext_instance_free);
}
void
lysp_ext_free(struct ly_ctx *ctx, struct lysp_ext *ext)
{
- FREE_STRING(ctx, ext->name);
- FREE_STRING(ctx, ext->argument);
- FREE_STRING(ctx, ext->dsc);
- FREE_STRING(ctx, ext->ref);
+ lydict_remove(ctx, ext->name);
+ lydict_remove(ctx, ext->argument);
+ lydict_remove(ctx, ext->dsc);
+ lydict_remove(ctx, ext->ref);
FREE_ARRAY(ctx, ext->exts, lysp_ext_instance_free);
if (ext->compiled) {
lysc_extension_free(ctx, &ext->compiled);
@@ -129,43 +129,43 @@
void
lysp_feature_free(struct ly_ctx *ctx, struct lysp_feature *feat)
{
- FREE_STRING(ctx, feat->name);
+ lydict_remove(ctx, feat->name);
FREE_ARRAY(ctx, feat->iffeatures, lysp_qname_free);
FREE_ARRAY(ctx, feat->iffeatures_c, lysc_iffeature_free);
LY_ARRAY_FREE(feat->depfeatures);
- FREE_STRING(ctx, feat->dsc);
- FREE_STRING(ctx, feat->ref);
+ lydict_remove(ctx, feat->dsc);
+ lydict_remove(ctx, feat->ref);
FREE_ARRAY(ctx, feat->exts, lysp_ext_instance_free);
}
void
lysp_ident_free(struct ly_ctx *ctx, struct lysp_ident *ident)
{
- FREE_STRING(ctx, ident->name);
+ lydict_remove(ctx, ident->name);
FREE_ARRAY(ctx, ident->iffeatures, lysp_qname_free);
FREE_STRINGS(ctx, ident->bases);
- FREE_STRING(ctx, ident->dsc);
- FREE_STRING(ctx, ident->ref);
+ lydict_remove(ctx, ident->dsc);
+ lydict_remove(ctx, ident->ref);
FREE_ARRAY(ctx, ident->exts, lysp_ext_instance_free);
}
void
lysp_restr_free(struct ly_ctx *ctx, struct lysp_restr *restr)
{
- FREE_STRING(ctx, restr->arg.str);
- FREE_STRING(ctx, restr->emsg);
- FREE_STRING(ctx, restr->eapptag);
- FREE_STRING(ctx, restr->dsc);
- FREE_STRING(ctx, restr->ref);
+ lydict_remove(ctx, restr->arg.str);
+ lydict_remove(ctx, restr->emsg);
+ lydict_remove(ctx, restr->eapptag);
+ lydict_remove(ctx, restr->dsc);
+ lydict_remove(ctx, restr->ref);
FREE_ARRAY(ctx, restr->exts, lysp_ext_instance_free);
}
static void
lysp_type_enum_free(struct ly_ctx *ctx, struct lysp_type_enum *item)
{
- FREE_STRING(ctx, item->name);
- FREE_STRING(ctx, item->dsc);
- FREE_STRING(ctx, item->ref);
+ lydict_remove(ctx, item->name);
+ lydict_remove(ctx, item->dsc);
+ lydict_remove(ctx, item->ref);
FREE_ARRAY(ctx, item->iffeatures, lysp_qname_free);
FREE_ARRAY(ctx, item->exts, lysp_ext_instance_free);
}
@@ -175,7 +175,7 @@
void
lysp_type_free(struct ly_ctx *ctx, struct lysp_type *type)
{
- FREE_STRING(ctx, type->name);
+ lydict_remove(ctx, type->name);
FREE_MEMBER(ctx, type->range, lysp_restr_free);
FREE_MEMBER(ctx, type->length, lysp_restr_free);
FREE_ARRAY(ctx, type->patterns, lysp_restr_free);
@@ -193,11 +193,11 @@
void
lysp_tpdf_free(struct ly_ctx *ctx, struct lysp_tpdf *tpdf)
{
- FREE_STRING(ctx, tpdf->name);
- FREE_STRING(ctx, tpdf->units);
- FREE_STRING(ctx, tpdf->dflt.str);
- FREE_STRING(ctx, tpdf->dsc);
- FREE_STRING(ctx, tpdf->ref);
+ lydict_remove(ctx, tpdf->name);
+ lydict_remove(ctx, tpdf->units);
+ lydict_remove(ctx, tpdf->dflt.str);
+ lydict_remove(ctx, tpdf->dsc);
+ lydict_remove(ctx, tpdf->ref);
FREE_ARRAY(ctx, tpdf->exts, lysp_ext_instance_free);
lysp_type_free(ctx, &tpdf->type);
@@ -227,9 +227,9 @@
void
lysp_when_free(struct ly_ctx *ctx, struct lysp_when *when)
{
- FREE_STRING(ctx, when->cond);
- FREE_STRING(ctx, when->dsc);
- FREE_STRING(ctx, when->ref);
+ lydict_remove(ctx, when->cond);
+ lydict_remove(ctx, when->dsc);
+ lydict_remove(ctx, when->ref);
FREE_ARRAY(ctx, when->exts, lysp_ext_instance_free);
}
@@ -253,7 +253,7 @@
lysp_qname_free(struct ly_ctx *ctx, struct lysp_qname *qname)
{
if (qname) {
- FREE_STRING(ctx, qname->str);
+ lydict_remove(ctx, qname->str);
}
}
@@ -270,14 +270,14 @@
break;
case LYS_DEV_ADD:
case LYS_DEV_DELETE: /* compatible for dynamically allocated data */
- FREE_STRING(ctx, add->units);
+ lydict_remove(ctx, add->units);
FREE_ARRAY(ctx, add->musts, lysp_restr_free);
FREE_ARRAY(ctx, add->uniques, lysp_qname_free);
FREE_ARRAY(ctx, add->dflts, lysp_qname_free);
break;
case LYS_DEV_REPLACE:
FREE_MEMBER(ctx, rpl->type, lysp_type_free);
- FREE_STRING(ctx, rpl->units);
+ lydict_remove(ctx, rpl->units);
lysp_qname_free(ctx, &rpl->dflt);
break;
default:
@@ -291,9 +291,9 @@
{
struct lysp_deviate *next, *iter;
- FREE_STRING(ctx, dev->nodeid);
- FREE_STRING(ctx, dev->dsc);
- FREE_STRING(ctx, dev->ref);
+ lydict_remove(ctx, dev->nodeid);
+ lydict_remove(ctx, dev->dsc);
+ lydict_remove(ctx, dev->ref);
LY_LIST_FOR_SAFE(dev->deviates, next, iter) {
lysp_deviate_free(ctx, iter);
free(iter);
@@ -304,12 +304,12 @@
void
lysp_refine_free(struct ly_ctx *ctx, struct lysp_refine *ref)
{
- FREE_STRING(ctx, ref->nodeid);
- FREE_STRING(ctx, ref->dsc);
- FREE_STRING(ctx, ref->ref);
+ lydict_remove(ctx, ref->nodeid);
+ lydict_remove(ctx, ref->dsc);
+ lydict_remove(ctx, ref->ref);
FREE_ARRAY(ctx, ref->iffeatures, lysp_qname_free);
FREE_ARRAY(ctx, ref->musts, lysp_restr_free);
- FREE_STRING(ctx, ref->presence);
+ lydict_remove(ctx, ref->presence);
FREE_ARRAY(ctx, ref->dflts, lysp_qname_free);
FREE_ARRAY(ctx, ref->exts, lysp_ext_instance_free);
}
@@ -321,9 +321,9 @@
struct lysp_restr *musts = lysp_node_musts(node);
struct lysp_when *when = lysp_node_when(node);
- FREE_STRING(ctx, node->name);
- FREE_STRING(ctx, node->dsc);
- FREE_STRING(ctx, node->ref);
+ lydict_remove(ctx, node->name);
+ lydict_remove(ctx, node->dsc);
+ lydict_remove(ctx, node->ref);
FREE_ARRAY(ctx, node->iffeatures, lysp_qname_free);
FREE_ARRAY(ctx, node->exts, lysp_ext_instance_free);
@@ -332,7 +332,7 @@
switch (node->nodetype) {
case LYS_CONTAINER:
- FREE_STRING(ctx, ((struct lysp_node_container *)node)->presence);
+ lydict_remove(ctx, ((struct lysp_node_container *)node)->presence);
FREE_ARRAY(ctx, ((struct lysp_node_container *)node)->typedefs, lysp_tpdf_free);
LY_LIST_FOR_SAFE(&((struct lysp_node_container *)node)->groupings->node, next, child) {
lysp_node_free(ctx, child);
@@ -349,16 +349,16 @@
break;
case LYS_LEAF:
lysp_type_free(ctx, &((struct lysp_node_leaf *)node)->type);
- FREE_STRING(ctx, ((struct lysp_node_leaf *)node)->units);
- FREE_STRING(ctx, ((struct lysp_node_leaf *)node)->dflt.str);
+ lydict_remove(ctx, ((struct lysp_node_leaf *)node)->units);
+ lydict_remove(ctx, ((struct lysp_node_leaf *)node)->dflt.str);
break;
case LYS_LEAFLIST:
lysp_type_free(ctx, &((struct lysp_node_leaflist *)node)->type);
- FREE_STRING(ctx, ((struct lysp_node_leaflist *)node)->units);
+ lydict_remove(ctx, ((struct lysp_node_leaflist *)node)->units);
FREE_ARRAY(ctx, ((struct lysp_node_leaflist *)node)->dflts, lysp_qname_free);
break;
case LYS_LIST:
- FREE_STRING(ctx, ((struct lysp_node_list *)node)->key);
+ lydict_remove(ctx, ((struct lysp_node_list *)node)->key);
FREE_ARRAY(ctx, ((struct lysp_node_list *)node)->typedefs, lysp_tpdf_free);
LY_LIST_FOR_SAFE(&((struct lysp_node_list *)node)->groupings->node, next, child) {
lysp_node_free(ctx, child);
@@ -378,7 +378,7 @@
LY_LIST_FOR_SAFE(((struct lysp_node_choice *)node)->child, next, child) {
lysp_node_free(ctx, child);
}
- FREE_STRING(ctx, ((struct lysp_node_choice *)node)->dflt.str);
+ lydict_remove(ctx, ((struct lysp_node_choice *)node)->dflt.str);
break;
case LYS_CASE:
LY_LIST_FOR_SAFE(((struct lysp_node_case *)node)->child, next, child) {
@@ -481,13 +481,13 @@
if (module->is_submod) {
struct lysp_submodule *submod = (struct lysp_submodule *)module;
- FREE_STRING(ctx, submod->name);
- FREE_STRING(ctx, submod->filepath);
- FREE_STRING(ctx, submod->prefix);
- FREE_STRING(ctx, submod->org);
- FREE_STRING(ctx, submod->contact);
- FREE_STRING(ctx, submod->dsc);
- FREE_STRING(ctx, submod->ref);
+ lydict_remove(ctx, submod->name);
+ lydict_remove(ctx, submod->filepath);
+ lydict_remove(ctx, submod->prefix);
+ lydict_remove(ctx, submod->org);
+ lydict_remove(ctx, submod->contact);
+ lydict_remove(ctx, submod->dsc);
+ lydict_remove(ctx, submod->ref);
}
free(module);
@@ -499,8 +499,8 @@
if (--(*ext)->refcount) {
return;
}
- FREE_STRING(ctx, (*ext)->name);
- FREE_STRING(ctx, (*ext)->argument);
+ lydict_remove(ctx, (*ext)->name);
+ lydict_remove(ctx, (*ext)->argument);
FREE_ARRAY(ctx, (*ext)->exts, lysc_ext_instance_free);
free(*ext);
}
@@ -514,7 +514,7 @@
if (ext->def) {
lysc_extension_free(ctx, &ext->def);
}
- FREE_STRING(ctx, ext->argument);
+ lydict_remove(ctx, ext->argument);
FREE_ARRAY(ctx, ext->exts, lysc_ext_instance_free);
}
@@ -533,8 +533,8 @@
}
lyxp_expr_free(ctx, (*w)->cond);
lysc_prefixes_free((*w)->prefixes);
- FREE_STRING(ctx, (*w)->dsc);
- FREE_STRING(ctx, (*w)->ref);
+ lydict_remove(ctx, (*w)->dsc);
+ lydict_remove(ctx, (*w)->ref);
FREE_ARRAY(ctx, (*w)->exts, lysc_ext_instance_free);
free(*w);
}
@@ -544,19 +544,19 @@
{
lyxp_expr_free(ctx, must->cond);
lysc_prefixes_free(must->prefixes);
- FREE_STRING(ctx, must->emsg);
- FREE_STRING(ctx, must->eapptag);
- FREE_STRING(ctx, must->dsc);
- FREE_STRING(ctx, must->ref);
+ lydict_remove(ctx, must->emsg);
+ lydict_remove(ctx, must->eapptag);
+ lydict_remove(ctx, must->dsc);
+ lydict_remove(ctx, must->ref);
FREE_ARRAY(ctx, must->exts, lysc_ext_instance_free);
}
void
lysc_ident_free(struct ly_ctx *ctx, struct lysc_ident *ident)
{
- FREE_STRING(ctx, ident->name);
- FREE_STRING(ctx, ident->dsc);
- FREE_STRING(ctx, ident->ref);
+ lydict_remove(ctx, ident->name);
+ lydict_remove(ctx, ident->dsc);
+ lydict_remove(ctx, ident->ref);
LY_ARRAY_FREE(ident->derived);
FREE_ARRAY(ctx, ident->exts, lysc_ext_instance_free);
}
@@ -565,10 +565,10 @@
lysc_range_free(struct ly_ctx *ctx, struct lysc_range *range)
{
LY_ARRAY_FREE(range->parts);
- FREE_STRING(ctx, range->eapptag);
- FREE_STRING(ctx, range->emsg);
- FREE_STRING(ctx, range->dsc);
- FREE_STRING(ctx, range->ref);
+ lydict_remove(ctx, range->eapptag);
+ lydict_remove(ctx, range->emsg);
+ lydict_remove(ctx, range->dsc);
+ lydict_remove(ctx, range->ref);
FREE_ARRAY(ctx, range->exts, lysc_ext_instance_free);
}
@@ -579,11 +579,11 @@
return;
}
pcre2_code_free((*pattern)->code);
- FREE_STRING(ctx, (*pattern)->expr);
- FREE_STRING(ctx, (*pattern)->eapptag);
- FREE_STRING(ctx, (*pattern)->emsg);
- FREE_STRING(ctx, (*pattern)->dsc);
- FREE_STRING(ctx, (*pattern)->ref);
+ lydict_remove(ctx, (*pattern)->expr);
+ lydict_remove(ctx, (*pattern)->eapptag);
+ lydict_remove(ctx, (*pattern)->emsg);
+ lydict_remove(ctx, (*pattern)->dsc);
+ lydict_remove(ctx, (*pattern)->ref);
FREE_ARRAY(ctx, (*pattern)->exts, lysc_ext_instance_free);
free(*pattern);
}
@@ -591,9 +591,9 @@
static void
lysc_enum_item_free(struct ly_ctx *ctx, struct lysc_type_bitenum_item *item)
{
- FREE_STRING(ctx, item->name);
- FREE_STRING(ctx, item->dsc);
- FREE_STRING(ctx, item->ref);
+ lydict_remove(ctx, item->name);
+ lydict_remove(ctx, item->dsc);
+ lydict_remove(ctx, item->ref);
FREE_ARRAY(ctx, item->exts, lysc_ext_instance_free);
}
@@ -720,7 +720,7 @@
if (node->type) {
lysc_type_free(ctx, node->type);
}
- FREE_STRING(ctx, node->units);
+ lydict_remove(ctx, node->units);
if (node->dflt) {
node->dflt->realtype->plugin->free(ctx, node->dflt);
lysc_type_free(ctx, (struct lysc_type *)node->dflt->realtype);
@@ -738,7 +738,7 @@
if (node->type) {
lysc_type_free(ctx, node->type);
}
- FREE_STRING(ctx, node->units);
+ lydict_remove(ctx, node->units);
LY_ARRAY_FOR(node->dflts, u) {
node->dflts[u]->realtype->plugin->free(ctx, node->dflts[u]);
lysc_type_free(ctx, (struct lysc_type *)node->dflts[u]->realtype);
@@ -807,9 +807,9 @@
ly_bool inout = 0;
/* common part */
- FREE_STRING(ctx, node->name);
- FREE_STRING(ctx, node->dsc);
- FREE_STRING(ctx, node->ref);
+ lydict_remove(ctx, node->name);
+ lydict_remove(ctx, node->dsc);
+ lydict_remove(ctx, node->ref);
/* nodetype-specific part */
switch (node->nodetype) {
@@ -970,15 +970,15 @@
LY_ARRAY_FREE(module->augmented_by);
LY_ARRAY_FREE(module->deviated_by);
- FREE_STRING(module->ctx, module->name);
- FREE_STRING(module->ctx, module->revision);
- FREE_STRING(module->ctx, module->ns);
- FREE_STRING(module->ctx, module->prefix);
- FREE_STRING(module->ctx, module->filepath);
- FREE_STRING(module->ctx, module->org);
- FREE_STRING(module->ctx, module->contact);
- FREE_STRING(module->ctx, module->dsc);
- FREE_STRING(module->ctx, module->ref);
+ lydict_remove(module->ctx, module->name);
+ lydict_remove(module->ctx, module->revision);
+ lydict_remove(module->ctx, module->ns);
+ lydict_remove(module->ctx, module->prefix);
+ lydict_remove(module->ctx, module->filepath);
+ lydict_remove(module->ctx, module->org);
+ lydict_remove(module->ctx, module->contact);
+ lydict_remove(module->ctx, module->dsc);
+ lydict_remove(module->ctx, module->ref);
free(module);
}
@@ -1016,7 +1016,7 @@
if (!str) {
break;
}
- FREE_STRING(ctx, str);
+ lydict_remove(ctx, str);
} else {
/* multiple items */
const char **strs = *((const char ***)substmts[u].storage);
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index deb08bb..51de253 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -564,7 +564,7 @@
* @brief Macro to free [sized array](@ref sizedarrays) of strings stored in the context's dictionary. The ARRAY itself is also freed,
* but the memory is not sanitized.
*/
-#define FREE_STRINGS(CTX, ARRAY) {LY_ARRAY_COUNT_TYPE c__; LY_ARRAY_FOR(ARRAY, c__){FREE_STRING(CTX, ARRAY[c__]);}LY_ARRAY_FREE(ARRAY);}
+#define FREE_STRINGS(CTX, ARRAY) {LY_ARRAY_COUNT_TYPE c__; LY_ARRAY_FOR(ARRAY, c__){lydict_remove(CTX, ARRAY[c__]);}LY_ARRAY_FREE(ARRAY);}
/**
* @brief Free the printable YANG schema tree structure. Works for both modules and submodules.
diff --git a/tests/utests/schema/test_parser_yin.c b/tests/utests/schema/test_parser_yin.c
index a51fcf3..611bf46 100644
--- a/tests/utests/schema/test_parser_yin.c
+++ b/tests/utests/schema/test_parser_yin.c
@@ -577,16 +577,16 @@
lysp_ext_instance_free(UTEST_LYCTX, exts);
lysp_when_free(UTEST_LYCTX, when_p);
lysp_ext_free(UTEST_LYCTX, ext_def);
- FREE_STRING(UTEST_LYCTX, *if_features);
- FREE_STRING(UTEST_LYCTX, error_message);
- FREE_STRING(UTEST_LYCTX, app_tag);
- FREE_STRING(UTEST_LYCTX, units);
- FREE_STRING(UTEST_LYCTX, patter_type.patterns->arg.str);
- FREE_STRING(UTEST_LYCTX, def.str);
- FREE_STRING(UTEST_LYCTX, range_type.range->arg.str);
- FREE_STRING(UTEST_LYCTX, len_type.length->arg.str);
- FREE_STRING(UTEST_LYCTX, enum_type.enums->name);
- FREE_STRING(UTEST_LYCTX, value);
+ lydict_remove(UTEST_LYCTX, *if_features);
+ lydict_remove(UTEST_LYCTX, error_message);
+ lydict_remove(UTEST_LYCTX, app_tag);
+ lydict_remove(UTEST_LYCTX, units);
+ lydict_remove(UTEST_LYCTX, patter_type.patterns->arg.str);
+ lydict_remove(UTEST_LYCTX, def.str);
+ lydict_remove(UTEST_LYCTX, range_type.range->arg.str);
+ lydict_remove(UTEST_LYCTX, len_type.length->arg.str);
+ lydict_remove(UTEST_LYCTX, enum_type.enums->name);
+ lydict_remove(UTEST_LYCTX, value);
LY_ARRAY_FREE(if_features);
LY_ARRAY_FREE(exts);
LY_ARRAY_FREE(ext_def);
@@ -865,7 +865,7 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[1]), LYEXT_SUBSTMT_ORGANIZATION);
assert_string_equal(value, "organization...");
- FREE_STRING(UTEST_LYCTX, value);
+ lydict_remove(UTEST_LYCTX, value);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
value = NULL;
exts = NULL;
@@ -877,7 +877,7 @@
assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_CONTACT);
assert_string_equal(value, "contact...");
- FREE_STRING(UTEST_LYCTX, value);
+ lydict_remove(UTEST_LYCTX, value);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
value = NULL;
@@ -889,7 +889,7 @@
assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_DESCRIPTION);
assert_string_equal(value, "description...");
- FREE_STRING(UTEST_LYCTX, value);
+ lydict_remove(UTEST_LYCTX, value);
value = NULL;
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
@@ -901,7 +901,7 @@
assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);
assert_string_equal(value, "reference...");
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_REFERENCE);
- FREE_STRING(UTEST_LYCTX, value);
+ lydict_remove(UTEST_LYCTX, value);
value = NULL;
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
@@ -912,7 +912,7 @@
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_EVALID);
CHECK_LOG_CTX("Unexpected attribute \"invalid\" of \"reference\" element.", "Line number 1.");
- FREE_STRING(UTEST_LYCTX, value);
+ lydict_remove(UTEST_LYCTX, value);
value = NULL;
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
@@ -930,7 +930,7 @@
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_EVALID);
CHECK_LOG_CTX("Sub-element \"text\" of \"reference\" element must be defined as it's first sub-element.", "Line number 1.");
- FREE_STRING(UTEST_LYCTX, value);
+ lydict_remove(UTEST_LYCTX, value);
value = NULL;
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
@@ -1163,7 +1163,7 @@
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
flags = 0;
- FREE_STRING(UTEST_LYCTX, arg);
+ lydict_remove(UTEST_LYCTX, arg);
arg = NULL;
/* min subelems */
@@ -1174,7 +1174,7 @@
assert_int_equal(test_element_helper(state, data, &arg_meta, NULL, NULL), LY_SUCCESS);
assert_string_equal(arg, "arg");
assert_true(flags == 0);
- FREE_STRING(UTEST_LYCTX, arg);
+ lydict_remove(UTEST_LYCTX, arg);
}
static void
@@ -1196,7 +1196,7 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BASE);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
- FREE_STRING(UTEST_LYCTX, *bases);
+ lydict_remove(UTEST_LYCTX, *bases);
LY_ARRAY_FREE(bases);
/* as type subelement */
@@ -1211,7 +1211,7 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BASE);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
- FREE_STRING(UTEST_LYCTX, *type.bases);
+ lydict_remove(UTEST_LYCTX, *type.bases);
LY_ARRAY_FREE(type.bases);
}
@@ -1232,7 +1232,7 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BELONGSTO);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
- FREE_STRING(UTEST_LYCTX, submod.prefix);
+ lydict_remove(UTEST_LYCTX, submod.prefix);
data = ELEMENT_WRAPPER_START "<belongs-to module=\"module-name\"></belongs-to>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &submod, NULL, NULL), LY_EVALID);
@@ -1278,7 +1278,7 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_DEFAULT);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
- FREE_STRING(UTEST_LYCTX, val.str);
+ lydict_remove(UTEST_LYCTX, val.str);
val.str = NULL;
data = ELEMENT_WRAPPER_START "<default/>" ELEMENT_WRAPPER_END;
@@ -1299,7 +1299,7 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ERRTAG);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
- FREE_STRING(UTEST_LYCTX, val);
+ lydict_remove(UTEST_LYCTX, val);
val = NULL;
data = ELEMENT_WRAPPER_START "<error-app-tag/>" ELEMENT_WRAPPER_END;
@@ -1320,7 +1320,7 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ERRMSG);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
- FREE_STRING(UTEST_LYCTX, val);
+ lydict_remove(UTEST_LYCTX, val);
data = ELEMENT_WRAPPER_START "<error-message></error-message>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);
@@ -1380,7 +1380,7 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_IFFEATURE);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
- FREE_STRING(UTEST_LYCTX, *iffeatures);
+ lydict_remove(UTEST_LYCTX, *iffeatures);
LY_ARRAY_FREE(iffeatures);
iffeatures = NULL;
@@ -1448,14 +1448,14 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_MODIFIER);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
- FREE_STRING(UTEST_LYCTX, pat);
+ lydict_remove(UTEST_LYCTX, pat);
assert_int_equal(LY_SUCCESS, lydict_insert(UTEST_LYCTX, "\006pattern", 8, &pat));
data = ELEMENT_WRAPPER_START "<modifier value=\"invert\" />" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &pat, NULL, NULL), LY_EVALID);
CHECK_LOG_CTX("Invalid value \"invert\" of \"value\" attribute in \"modifier\" element. "
"Only valid value is \"invert-match\".", "Line number 1.");
- FREE_STRING(UTEST_LYCTX, pat);
+ lydict_remove(UTEST_LYCTX, pat);
}
static void
@@ -1471,7 +1471,7 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_NAMESPACE);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
- FREE_STRING(UTEST_LYCTX, ns);
+ lydict_remove(UTEST_LYCTX, ns);
data = ELEMENT_WRAPPER_START "<namespace/>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &ns, NULL, NULL), LY_EVALID);
@@ -1597,12 +1597,12 @@
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_PREFIX);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
exts = NULL;
- FREE_STRING(UTEST_LYCTX, value);
+ lydict_remove(UTEST_LYCTX, value);
data = ELEMENT_WRAPPER_START "<prefix value=\"pref\"/>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &value, NULL, NULL), LY_SUCCESS);
assert_string_equal(value, "pref");
- FREE_STRING(UTEST_LYCTX, value);
+ lydict_remove(UTEST_LYCTX, value);
}
static void
@@ -1699,14 +1699,14 @@
assert_string_equal(*values, "tag");
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_UNIQUE);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
- FREE_STRING(UTEST_LYCTX, *values);
+ lydict_remove(UTEST_LYCTX, *values);
LY_ARRAY_FREE(values);
values = NULL;
data = ELEMENT_WRAPPER_START "<unique tag=\"tag\"/>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &values, NULL, NULL), LY_SUCCESS);
assert_string_equal(*values, "tag");
- FREE_STRING(UTEST_LYCTX, *values);
+ lydict_remove(UTEST_LYCTX, *values);
LY_ARRAY_FREE(values);
values = NULL;
}
@@ -1723,13 +1723,13 @@
assert_string_equal(values, "name");
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_UNITS);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
- FREE_STRING(UTEST_LYCTX, values);
+ lydict_remove(UTEST_LYCTX, values);
values = NULL;
data = ELEMENT_WRAPPER_START "<units name=\"name\"/>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &values, NULL, NULL), LY_SUCCESS);
assert_string_equal(values, "name");
- FREE_STRING(UTEST_LYCTX, values);
+ lydict_remove(UTEST_LYCTX, values);
values = NULL;
}
@@ -1770,17 +1770,17 @@
data = ELEMENT_WRAPPER_START "<text>text</text>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS);
assert_string_equal(val, "text");
- FREE_STRING(UTEST_LYCTX, val);
+ lydict_remove(UTEST_LYCTX, val);
data = "<error-message xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <value>text</value> </error-message>";
assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS);
assert_string_equal(val, "text");
- FREE_STRING(UTEST_LYCTX, val);
+ lydict_remove(UTEST_LYCTX, val);
data = ELEMENT_WRAPPER_START "<text></text>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS);
assert_string_equal("", val);
- FREE_STRING(UTEST_LYCTX, val);
+ lydict_remove(UTEST_LYCTX, val);
}
static void
@@ -2247,12 +2247,12 @@
assert_string_equal(val, "presence-val");
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_PRESENCE);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
- FREE_STRING(UTEST_LYCTX, val);
+ lydict_remove(UTEST_LYCTX, val);
data = ELEMENT_WRAPPER_START "<presence value=\"presence-val\"/>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS);
assert_string_equal(val, "presence-val");
- FREE_STRING(UTEST_LYCTX, val);
+ lydict_remove(UTEST_LYCTX, val);
data = ELEMENT_WRAPPER_START "<presence/>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);
@@ -2271,12 +2271,12 @@
assert_string_equal(val, "key-value");
TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_KEY);
FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);
- FREE_STRING(UTEST_LYCTX, val);
+ lydict_remove(UTEST_LYCTX, val);
data = ELEMENT_WRAPPER_START "<key value=\"key-value\"/>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS);
assert_string_equal(val, "key-value");
- FREE_STRING(UTEST_LYCTX, val);
+ lydict_remove(UTEST_LYCTX, val);
data = ELEMENT_WRAPPER_START "<key/>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);