normal: plug memory leaks on exit paths #624

This commit is contained in:
nick black 2020-06-03 04:50:09 -04:00
parent e32e4d9744
commit 1c05994a05
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -114,6 +114,7 @@ offset(uint32_t* rgba, int y, int x, int dx){
// make a pixel array out from the center, blitting it as we go // make a pixel array out from the center, blitting it as we go
int normal_demo(struct notcurses* nc){ int normal_demo(struct notcurses* nc){
int dy, dx; int dy, dx;
int r = -1;
struct ncplane* nstd = notcurses_stddim_yx(nc, &dy, &dx); struct ncplane* nstd = notcurses_stddim_yx(nc, &dy, &dx);
ncplane_erase(nstd); ncplane_erase(nstd);
cell c = CELL_SIMPLE_INITIALIZER(' '); cell c = CELL_SIMPLE_INITIALIZER(' ');
@ -153,7 +154,10 @@ int normal_demo(struct notcurses* nc){
if(ncblit_rgba(nstd, 0, 0, dx * sizeof(*rgba), rgba, 0, 0, dy, dx) < 0){ if(ncblit_rgba(nstd, 0, 0, dx * sizeof(*rgba), rgba, 0, 0, dy, dx) < 0){
goto err; goto err;
} }
DEMO_RENDER(nc); if( (r = demo_render(nc)) ){
goto err;
}
r = -1;
demo_nanosleep(nc, &scaled); demo_nanosleep(nc, &scaled);
} }
free(rgba); free(rgba);
@ -161,7 +165,7 @@ int normal_demo(struct notcurses* nc){
// we can't resize (and thus can't rotate) the standard plane, so dup it // we can't resize (and thus can't rotate) the standard plane, so dup it
n = ncplane_dup(nstd, NULL); n = ncplane_dup(nstd, NULL);
if(n == NULL){ if(n == NULL){
return -1; goto err;
} }
ncplane_erase(nstd); ncplane_erase(nstd);
ncplane_cursor_move_yx(n, 0, 0); ncplane_cursor_move_yx(n, 0, 0);
@ -193,5 +197,5 @@ int normal_demo(struct notcurses* nc){
err: err:
free(rgba); free(rgba);
ncplane_destroy(n); ncplane_destroy(n);
return -1; return r;
} }