mie: implement value cleanup

This commit is contained in:
2025-04-13 19:25:23 +01:00
parent 44aec9a121
commit a7233a6cf6
6 changed files with 102 additions and 10 deletions

View File

@@ -55,15 +55,8 @@ struct mie_ctx *mie_ctx_create(void)
void mie_ctx_destroy(struct mie_ctx *ctx)
{
if (ctx->ctx_true) {
mie_value_destroy(MIE_VALUE(ctx->ctx_true));
ctx->ctx_true = NULL;
}
if (ctx->ctx_false) {
mie_value_destroy(MIE_VALUE(ctx->ctx_false));
ctx->ctx_false = NULL;
}
ctx->ctx_true = NULL;
ctx->ctx_false = NULL;
b_btree_iterator it = {};
b_btree_iterator_begin(&ctx->ctx_int_cache, &it);
@@ -84,6 +77,12 @@ void mie_ctx_destroy(struct mie_ctx *ctx)
free(entry);
}
const size_t nr_types = sizeof ctx->ctx_types / sizeof ctx->ctx_types[0];
for (size_t i = 0; i < nr_types; i++) {
mie_value_destroy(MIE_VALUE(ctx->ctx_types[i]));
ctx->ctx_types[i] = NULL;
}
free(ctx);
}