shithub: riscv

Download patch

ref: dc2c8dca5bafe537b446a80c333b77513eeaf765
parent: a1066aa9921275bad1d720fa9433482e08dd77d8
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Nov 19 16:01:36 EST 2014

games/md, games/snes: fix memory leak on resize

--- a/sys/src/games/md/md.c
+++ b/sys/src/games/md/md.c
@@ -121,7 +121,9 @@
 	originwindow(screen, Pt(0, 0), screen->r.min);
 	p = divpt(addpt(screen->r.min, screen->r.max), 2);
 	picr = (Rectangle){subpt(p, Pt(scale * 160, scale * 112)), addpt(p, Pt(scale * 160, scale * 112))};
+	if(tmp != nil) freeimage(tmp);
 	tmp = allocimage(display, Rect(0, 0, scale * 320, scale > 1 ? 1 : scale * 224), XRGB32, scale > 1, 0);
+	if(bg != nil) freeimage(bg);
 	bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
 	draw(screen, screen->r, bg, nil, ZP);	
 }
--- a/sys/src/games/snes/snes.c
+++ b/sys/src/games/snes/snes.c
@@ -180,7 +180,9 @@
 
 	p = divpt(addpt(screen->r.min, screen->r.max), 2);
 	picr = (Rectangle){subpt(p, Pt(scale * 128, scale * 112)), addpt(p, Pt(scale * 128, scale * 127))};
+	if(tmp != nil) freeimage(tmp);
 	tmp = allocimage(display, Rect(0, 0, scale * 256, scale > 1 ? 1 : scale * 239), RGB15, scale > 1, 0);
+	if(bg != nil) freeimage(bg);
 	bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
 	draw(screen, screen->r, bg, nil, ZP);	
 }