uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 8bbe5c1dfddab6b7daccb67919954499868b7af1
parent 831014e8112cd4e8ede0dc96edad17b04795ddad
Author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Date:   Sat, 25 Dec 2021 16:06:30 +0100

ppu_resize: f49143782abd21bb9b53ba5207ac09ab1e4da8e0 was wrong. keep successfully reallocated layers

Diffstat:
Msrc/devices/ppu.c | 17+++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/devices/ppu.c b/src/devices/ppu.c @@ -57,17 +57,14 @@ ppu_resize(Ppu *p, Uint16 width, Uint16 height) Uint8 *bg = realloc(p->bg.pixels, width * height), *fg = realloc(p->fg.pixels, width * height); - if(!bg || !fg) { - free(bg); - free(fg); - return; + if(bg) p->bg.pixels = bg; + if(fg) p->fg.pixels = fg; + if(bg && fg) { + p->width = width; + p->height = height; + ppu_clear(p, &p->bg); + ppu_clear(p, &p->fg); } - p->bg.pixels = bg; - p->fg.pixels = fg; - p->width = width; - p->height = height; - ppu_clear(p, &p->bg); - ppu_clear(p, &p->fg); } void