Skip to content

Commit

Permalink
schema compile REFACTOR free context handling
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvasko committed Sep 11, 2024
1 parent a8e855b commit 0c9a1d3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/parser_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ lyd_parser_notif_eventtime_validate(const struct lyd_node *node)
{
LY_ERR rc = LY_SUCCESS;
struct ly_ctx *ctx = (struct ly_ctx *)LYD_CTX(node);
struct lysc_ctx cctx;
struct lysc_ctx cctx = {0};
const struct lys_module *mod1, *mod2;
const struct lysc_node *schema;
LY_ARRAY_COUNT_TYPE u;
Expand Down
10 changes: 5 additions & 5 deletions src/schema_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ lys_identity_precompile(struct lysc_ctx *ctx_sc, struct ly_ctx *ctx, struct lysp
const struct lysp_ident *identities_p, struct lysc_ident **identities)
{
LY_ARRAY_COUNT_TYPE u;
struct lysc_ctx cctx;
struct lysc_ctx cctx = {0};
struct lysc_ident *ident;
LY_ERR ret = LY_SUCCESS;

Expand Down Expand Up @@ -1477,7 +1477,7 @@ lys_compile_unres_depset(struct ly_ctx *ctx, struct lys_glob_unres *unres)
}

cleanup:
lysf_ctx_erase(&cctx.free_ctx);
assert(!cctx.free_ctx.ext_set.count);
return ret;
}

Expand Down Expand Up @@ -1557,8 +1557,8 @@ lys_compile_depset_r(struct ly_ctx *ctx, struct ly_set *dep_set, struct lys_glob
}

cleanup:
assert(!fctx.ext_set.count);
lys_compile_unres_depset_erase(ctx, unres);
lysf_ctx_erase(&fctx);
return ret;
}

Expand Down Expand Up @@ -1702,7 +1702,7 @@ lys_compile_unres_mod_erase(struct lysc_ctx *ctx, ly_bool error)
LY_ERR
lys_compile(struct lys_module *mod, struct lys_depset_unres *unres)
{
struct lysc_ctx ctx;
struct lysc_ctx ctx = {0};
struct lysc_module *mod_c = NULL;
struct lysp_module *sp;
struct lysp_submodule *submod;
Expand Down Expand Up @@ -1823,7 +1823,7 @@ LY_ERR
lys_compile_identities(struct lys_module *mod)
{
LY_ERR rc = LY_SUCCESS;
struct lysc_ctx ctx;
struct lysc_ctx ctx = {0};
struct lysp_submodule *submod;
LY_ARRAY_COUNT_TYPE u;

Expand Down
2 changes: 0 additions & 2 deletions src/schema_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ struct lysc_ctx {
* @param[in] CTX libyang context.
*/
#define LYSC_CTX_INIT_CTX(CCTX, CTX) \
memset(&(CCTX), 0, sizeof (CCTX)); \
(CCTX).ctx = (CTX); \
(CCTX).path_len = 1; \
(CCTX).path[0] = '/'; \
Expand All @@ -81,7 +80,6 @@ struct lysc_ctx {
* @param[in] EXT Ancestor extension instance.
*/
#define LYSC_CTX_INIT_PMOD(CCTX, PMOD, EXT) \
memset(&(CCTX), 0, sizeof (CCTX)); \
(CCTX).ctx = (PMOD)->mod->ctx; \
(CCTX).cur_mod = (PMOD)->mod; \
(CCTX).pmod = (PMOD); \
Expand Down
2 changes: 1 addition & 1 deletion src/schema_compile_amend.c
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,7 @@ lys_precompile_mod_augments_deviations(struct lysp_module *pmod, struct ly_set *
{
LY_ERR ret = LY_SUCCESS;
LY_ARRAY_COUNT_TYPE u, v;
struct lysc_ctx ctx;
struct lysc_ctx ctx = {0};
struct lys_module *m;
struct lysp_node_augment *aug;
struct ly_set set = {0};
Expand Down

0 comments on commit 0c9a1d3

Please sign in to comment.