Browse code

uxnemu: fix a memory leak (ram) in start() and reduce types clutter

Sigrid Solveig Haflínudóttir authored on 29/03/2022 17:23:59
Showing 1 changed files
... ...
@@ -263,7 +263,8 @@ load(Uxn *u, char *rom)
263 263
 static int
264 264
 start(Uxn *u, char *rom)
265 265
 {
266
-	if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8))))
266
+	free(u->ram);
267
+	if(!uxn_boot(u, calloc(0x10000, 1)))
267 268
 		return error("Boot", "Failed to start uxn.");
268 269
 	if(!load(u, rom))
269 270
 		return error("Boot", "Failed to load rom.");
... ...
@@ -474,7 +475,7 @@ int
474 475
 main(int argc, char **argv)
475 476
 {
476 477
 	SDL_DisplayMode DM;
477
-	Uxn u;
478
+	Uxn u = {0};
478 479
 	int i, loaded = 0;
479 480
 
480 481
 	if(!init())