Mercurial > repos > blastem
diff z80_to_x86.c @ 1592:31effaadf877
Fix some memory errors (mostly leaks) identified by valgrind
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 22 Jun 2018 23:10:27 -0700 |
parents | 5a6339e46917 |
children | 873a1330c3a9 |
line wrap: on
line diff
--- a/z80_to_x86.c Fri Jun 22 21:11:38 2018 -0700 +++ b/z80_to_x86.c Fri Jun 22 23:10:27 2018 -0700 @@ -3671,7 +3671,19 @@ 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); }