Skip to content

Commit 68b9634

Browse files
committed
path UPDATE context not required for freeing
1 parent 9d50e77 commit 68b9634

File tree

11 files changed

+25
-24
lines changed

11 files changed

+25
-24
lines changed

src/path.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,15 +1091,15 @@ ly_path_compile_deref(const struct ly_ctx *ctx, const struct lysc_node *ctx_node
10911091
}
10921092
lref = (const struct lysc_type_leafref *)deref_leaf_node->type;
10931093
LY_CHECK_GOTO(ret = ly_path_append(ctx, path2, path), cleanup);
1094-
ly_path_free(ctx, path2);
1094+
ly_path_free(path2);
10951095
path2 = NULL;
10961096

10971097
/* compile dereferenced leafref expression and append it to the path */
10981098
LY_CHECK_GOTO(ret = ly_path_compile_leafref(ctx, node2, top_ext, lref->path, oper, target, format, prefix_data,
10991099
&path2), cleanup);
11001100
node2 = path2[LY_ARRAY_COUNT(path2) - 1].node;
11011101
LY_CHECK_GOTO(ret = ly_path_append(ctx, path2, path), cleanup);
1102-
ly_path_free(ctx, path2);
1102+
ly_path_free(path2);
11031103
path2 = NULL;
11041104

11051105
/* properly parsed path must always continue with ')' and '/' */
@@ -1123,9 +1123,9 @@ ly_path_compile_deref(const struct ly_ctx *ctx, const struct lysc_node *ctx_node
11231123
LY_CHECK_GOTO(ret = ly_path_append(ctx, path2, path), cleanup);
11241124

11251125
cleanup:
1126-
ly_path_free(ctx, path2);
1126+
ly_path_free(path2);
11271127
if (ret) {
1128-
ly_path_free(ctx, *path);
1128+
ly_path_free(*path);
11291129
*path = NULL;
11301130
}
11311131
return ret;
@@ -1281,7 +1281,7 @@ _ly_path_compile(const struct ly_ctx *ctx, const struct lys_module *cur_mod, con
12811281

12821282
cleanup:
12831283
if (ret) {
1284-
ly_path_free(ctx, *path);
1284+
ly_path_free(*path);
12851285
*path = NULL;
12861286
}
12871287
LOG_LOCBACK(cur_node ? 1 : 0, 0);
@@ -1486,7 +1486,7 @@ ly_path_predicates_free(const struct ly_ctx *ctx, struct ly_path_predicate *pred
14861486
}
14871487

14881488
void
1489-
ly_path_free(const struct ly_ctx *ctx, struct ly_path *path)
1489+
ly_path_free(struct ly_path *path)
14901490
{
14911491
LY_ARRAY_COUNT_TYPE u;
14921492

@@ -1495,7 +1495,7 @@ ly_path_free(const struct ly_ctx *ctx, struct ly_path *path)
14951495
}
14961496

14971497
LY_ARRAY_FOR(path, u) {
1498-
ly_path_predicates_free(ctx, path[u].predicates);
1498+
ly_path_predicates_free(path[u].node->module->ctx, path[u].predicates);
14991499
}
15001500
LY_ARRAY_FREE(path);
15011501
}

src/path.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,8 @@ void ly_path_predicates_free(const struct ly_ctx *ctx, struct ly_path_predicate
257257
/**
258258
* @brief Free ly_path structure.
259259
*
260-
* @param[in] ctx libyang context.
261260
* @param[in] path The structure ([sized array](@ref sizedarrays)) to free.
262261
*/
263-
void ly_path_free(const struct ly_ctx *ctx, struct ly_path *path);
262+
void ly_path_free(struct ly_path *path);
264263

265264
#endif /* LY_PATH_H_ */

src/plugins_types.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -895,17 +895,17 @@ lyplg_type_lypath_new(const struct ly_ctx *ctx, const char *value, size_t value_
895895
ly_err_clean((struct ly_ctx *)ctx, e);
896896
}
897897

898-
ly_path_free(ctx, *path);
898+
ly_path_free(*path);
899899
*path = NULL;
900900
}
901901

902902
return ret;
903903
}
904904

905905
LIBYANG_API_DEF void
906-
lyplg_type_lypath_free(const struct ly_ctx *ctx, struct ly_path *path)
906+
lyplg_type_lypath_free(const struct ly_ctx *UNUSED(ctx), struct ly_path *path)
907907
{
908-
ly_path_free(ctx, path);
908+
ly_path_free(path);
909909
}
910910

911911
LIBYANG_API_DEF LY_ERR
@@ -1014,7 +1014,7 @@ lyplg_type_resolve_leafref_get_target_path(const struct lyxp_expr *path, const s
10141014
LY_CHECK_GOTO(lyxp_expr_parse(ctx_node->module->ctx, str_path, 0, 1, target_path), cleanup);
10151015

10161016
cleanup:
1017-
ly_path_free(ctx_node->module->ctx, p);
1017+
ly_path_free(p);
10181018
free(str_path);
10191019
return rc;
10201020
}

src/plugins_types/instanceid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ lyplg_type_free_instanceid(const struct ly_ctx *ctx, struct lyd_value *value)
307307
{
308308
lydict_remove(ctx, value->_canonical);
309309
value->_canonical = NULL;
310-
ly_path_free(ctx, value->target);
310+
ly_path_free(value->target);
311311
}
312312

313313
/**

src/schema_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ lys_compile_unres_leafref(struct lysc_ctx *ctx, const struct lysc_node *node, st
866866

867867
/* get the target node */
868868
target = p[LY_ARRAY_COUNT(p) - 1].node;
869-
ly_path_free(node->module->ctx, p);
869+
ly_path_free(p);
870870

871871
if (!(target->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
872872
LOGVAL(ctx->ctx, LYVE_REFERENCE, "Invalid leafref path \"%s\" - target node is %s instead of leaf or leaf-list.",
@@ -1456,7 +1456,7 @@ lys_compile_unres_depset(struct ly_ctx *ctx, struct lys_glob_unres *unres)
14561456
ret = ly_path_compile_leafref(cctx.ctx, l->node, cctx.ext, lref->path,
14571457
(l->node->flags & LYS_IS_OUTPUT) ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT, LY_PATH_TARGET_MANY,
14581458
LY_VALUE_SCHEMA_RESOLVED, lref->prefixes, &path);
1459-
ly_path_free(l->node->module->ctx, path);
1459+
ly_path_free(path);
14601460

14611461
assert(ret != LY_ERECOMPILE);
14621462
if (ret) {

src/tree_data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3595,7 +3595,7 @@ lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
35953595

35963596
cleanup:
35973597
lyxp_expr_free(LYD_CTX(ctx_node), expr);
3598-
ly_path_free(LYD_CTX(ctx_node), lypath);
3598+
ly_path_free(lypath);
35993599
return ret;
36003600
}
36013601

src/tree_data_new.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@ lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const struct ly
18231823
LY_ARRAY_INCREMENT(p);
18241824
}
18251825
}
1826-
ly_path_free(ctx, p);
1826+
ly_path_free(p);
18271827
if (!ret) {
18281828
/* set out params only on success */
18291829
if (new_parent) {

src/tree_schema.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ lys_find_path_atoms(const struct ly_ctx *ctx, const struct lysc_node *ctx_node,
644644
ret = lys_find_lypath_atoms(p, set);
645645

646646
cleanup:
647-
ly_path_free(ctx, p);
647+
ly_path_free(p);
648648
lyxp_expr_free(ctx, expr);
649649
return ret;
650650
}
@@ -679,7 +679,7 @@ lys_find_path(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const
679679
snode = p[LY_ARRAY_COUNT(p) - 1].node;
680680

681681
cleanup:
682-
ly_path_free(ctx, p);
682+
ly_path_free(p);
683683
lyxp_expr_free(ctx, expr);
684684
return snode;
685685
}

src/tree_schema_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,7 @@ lysc_node_lref_target(const struct lysc_node *node)
18291829

18301830
/* get the target node */
18311831
target = p[LY_ARRAY_COUNT(p) - 1].node;
1832-
ly_path_free(node->module->ctx, p);
1832+
ly_path_free(p);
18331833

18341834
return target;
18351835
}

src/xpath.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,7 +4042,7 @@ xpath_deref(struct lyxp_set **args, uint32_t UNUSED(arg_count), struct lyxp_set
40424042
if (!r) {
40434043
/* get the target node */
40444044
target = p[LY_ARRAY_COUNT(p) - 1].node;
4045-
ly_path_free(set->ctx, p);
4045+
ly_path_free(p);
40464046

40474047
LY_CHECK_RET(lyxp_set_scnode_insert_node(set, target, LYXP_NODE_ELEM, LYXP_AXIS_SELF, NULL));
40484048
} /* else the target was found before but is disabled so it was removed */
@@ -8272,7 +8272,9 @@ eval_name_test_with_predicate(const struct lyxp_expr *exp, uint32_t *tok_idx, en
82728272
options &= ~LYXP_SKIP_EXPR;
82738273
}
82748274
lydict_remove(set->ctx, ncname_dict);
8275-
ly_path_predicates_free(set->ctx, predicates);
8275+
if (predicates) {
8276+
ly_path_predicates_free(scnode->module->ctx, predicates);
8277+
}
82768278
return rc;
82778279
}
82788280

0 commit comments

Comments
 (0)