diff options
author | Michael Pavone <pavone@retrodev.com> | 2018-06-22 23:10:27 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2018-06-22 23:10:27 -0700 |
commit | e1d177b8429e4eb59f5a6e853009dbf97ab95068 (patch) | |
tree | 4733ff57c8a2fbac7470ca64d89852ae01908686 /z80_to_x86.c | |
parent | e9dcae6c35185d58f41d49b8952f9d55984532fd (diff) |
Fix some memory errors (mostly leaks) identified by valgrind
Diffstat (limited to 'z80_to_x86.c')
-rw-r--r-- | z80_to_x86.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/z80_to_x86.c b/z80_to_x86.c index d2341a2..cd51389 100644 --- a/z80_to_x86.c +++ b/z80_to_x86.c @@ -3671,7 +3671,19 @@ void z80_run(z80_context * context, uint32_t target_cycle) void z80_options_free(z80_options *opts) { + for (uint32_t address = 0; address < opts->gen.address_mask; address += NATIVE_CHUNK_SIZE) + { + uint32_t chunk = address / NATIVE_CHUNK_SIZE; + if (opts->gen.native_code_map[chunk].base) { + free(opts->gen.native_code_map[chunk].offsets); + } + } free(opts->gen.native_code_map); + uint32_t ram_inst_slots = ram_size(&opts->gen) / 1024; + for (uint32_t i = 0; i < ram_inst_slots; i++) + { + free(opts->gen.ram_inst_sizes[i]); + } free(opts->gen.ram_inst_sizes); free(opts); } |