schema compile REFACTOR free context handling
diff --git a/src/parser_common.c b/src/parser_common.c
index 6dbac08..5dadecf 100644
--- a/src/parser_common.c
+++ b/src/parser_common.c
@@ -70,7 +70,7 @@
 {
     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;
diff --git a/src/schema_compile.c b/src/schema_compile.c
index bb83147..d21f0dc 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -221,7 +221,7 @@
         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;
 
@@ -1477,7 +1477,7 @@
     }
 
 cleanup:
-    lysf_ctx_erase(&cctx.free_ctx);
+    assert(!cctx.free_ctx.ext_set.count);
     return ret;
 }
 
@@ -1557,8 +1557,8 @@
     }
 
 cleanup:
+    assert(!fctx.ext_set.count);
     lys_compile_unres_depset_erase(ctx, unres);
-    lysf_ctx_erase(&fctx);
     return ret;
 }
 
@@ -1702,7 +1702,7 @@
 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;
@@ -1823,7 +1823,7 @@
 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;
 
diff --git a/src/schema_compile.h b/src/schema_compile.h
index 49f75d2..8f67ce3 100644
--- a/src/schema_compile.h
+++ b/src/schema_compile.h
@@ -67,7 +67,6 @@
  * @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] = '/'; \
@@ -81,7 +80,6 @@
  * @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); \
diff --git a/src/schema_compile_amend.c b/src/schema_compile_amend.c
index 21cb632..6179220 100644
--- a/src/schema_compile_amend.c
+++ b/src/schema_compile_amend.c
@@ -2443,7 +2443,7 @@
 {
     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};