comparison m68k_core.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 e01adbe1a75b
children 24508cb54f87
comparison
equal deleted inserted replaced
1591:5cfc7e4a207e 1592:31effaadf877
1189 start_68k_context(context, address); 1189 start_68k_context(context, address);
1190 } 1190 }
1191 1191
1192 void m68k_options_free(m68k_options *opts) 1192 void m68k_options_free(m68k_options *opts)
1193 { 1193 {
1194 for (uint32_t address = 0; address < opts->gen.address_mask; address += NATIVE_CHUNK_SIZE)
1195 {
1196 uint32_t chunk = address / NATIVE_CHUNK_SIZE;
1197 if (opts->gen.native_code_map[chunk].base) {
1198 free(opts->gen.native_code_map[chunk].offsets);
1199 }
1200 }
1194 free(opts->gen.native_code_map); 1201 free(opts->gen.native_code_map);
1202 uint32_t ram_inst_slots = ram_size(&opts->gen) / 1024;
1203 for (uint32_t i = 0; i < ram_inst_slots; i++)
1204 {
1205 free(opts->gen.ram_inst_sizes[i]);
1206 }
1195 free(opts->gen.ram_inst_sizes); 1207 free(opts->gen.ram_inst_sizes);
1196 free(opts); 1208 free(opts);
1197 } 1209 }
1198 1210
1199 1211