diff options
author | Ting-Wei Lan <lantw44@gmail.com> | 2015-12-31 19:16:00 +0800 |
---|---|---|
committer | Ting-Wei Lan <lantw44@gmail.com> | 2015-12-31 19:16:29 +0800 |
commit | 64a1eb052290116cdc150a33fcea7bc0f2b4ad48 (patch) | |
tree | 63489fa548d72bc3c091e333215ce8e85b2c6371 | |
parent | f4f88342f1cda6491bf9f2f06fa859f51d7a4297 (diff) | |
download | compiler2015-64a1eb052290116cdc150a33fcea7bc0f2b4ad48.tar.gz compiler2015-64a1eb052290116cdc150a33fcea7bc0f2b4ad48.tar.zst compiler2015-64a1eb052290116cdc150a33fcea7bc0f2b4ad48.zip |
Properly deallocate the register pool
-rw-r--r-- | src/code-generation.c | 2 | ||||
-rw-r--r-- | src/state.c | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/code-generation.c b/src/code-generation.c index d193bc0..19a1000 100644 --- a/src/code-generation.c +++ b/src/code-generation.c @@ -225,6 +225,8 @@ void ccmmc_code_generation(CcmmcState *state) ccmmc_symbol_table_reopen_scope(state->table); state->reg_pool = ccmmc_register_init(); generate_program(state); + ccmmc_register_fini(state->reg_pool); + state->reg_pool = NULL; } // vim: set sw=4 ts=4 sts=4 et: diff --git a/src/state.c b/src/state.c index 0c643f6..9ac55f3 100644 --- a/src/state.c +++ b/src/state.c @@ -11,6 +11,7 @@ void ccmmc_state_init (CcmmcState *state) state->table = NULL; state->line_number = 1; state->asm_output = NULL; + state->reg_pool = NULL; } void ccmmc_state_fini (CcmmcState *state) @@ -24,6 +25,9 @@ void ccmmc_state_fini (CcmmcState *state) if (state->asm_output != NULL) { fclose(state->asm_output); } + if (state->reg_pool != NULL) { + ccmmc_register_fini(state->reg_pool); + } } // vim: set sw=4 ts=4 sts=4 et: |