mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
ncplane_resize_internal: realloc only when keepleny && !keepy #2426
This commit is contained in:
parent
7a99d00719
commit
78269365b4
@ -858,13 +858,13 @@ int ncplane_resize_internal(ncplane* n, int keepy, int keepx,
|
|||||||
// we might realloc instead of mallocing, in which case we NULL out
|
// we might realloc instead of mallocing, in which case we NULL out
|
||||||
// |preserved|. it must otherwise be free()d at the end.
|
// |preserved|. it must otherwise be free()d at the end.
|
||||||
nccell* preserved = n->fb;
|
nccell* preserved = n->fb;
|
||||||
if(cols == xlen && cols == keeplenx && keepy){
|
if(cols == xlen && cols == keeplenx && keepleny && !keepy){
|
||||||
// we need release the cells that we're losing, lest we leak EGCpool
|
// we need release the cells that we're losing, lest we leak EGCpool
|
||||||
// memory. unfortunately, this means we mutate the plane on the error case.
|
// memory. unfortunately, this means we mutate the plane on the error case.
|
||||||
// any solution would involve copying them out first. we only do this if
|
// any solution would involve copying them out first. we only do this if
|
||||||
// we're keeping some, as we otherwise drop the EGCpool in toto.
|
// we're keeping some, as we otherwise drop the EGCpool in toto.
|
||||||
if(keptarea && n->leny > ylen){
|
if(n->leny > keepleny){
|
||||||
for(unsigned y = ylen ; y < n->leny ; ++y){
|
for(unsigned y = keepleny ; y < n->leny ; ++y){
|
||||||
for(unsigned x = 0 ; x < n->lenx ; ++x){
|
for(unsigned x = 0 ; x < n->lenx ; ++x){
|
||||||
nccell_release(n, ncplane_cell_ref_yx(n, y, x));
|
nccell_release(n, ncplane_cell_ref_yx(n, y, x));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user