free auxvectors at ncplane free time, not sixel hide time #1440

This commit is contained in:
nick black 2021-04-27 21:17:12 -04:00 committed by Nick Black
parent 6ad7fcc7a9
commit 9c472a5d5e
4 changed files with 11 additions and 8 deletions

View File

@ -617,7 +617,7 @@ typedef struct notcurses {
unsigned stdio_blocking_save; // was stdio blocking at entry? restore on stop. unsigned stdio_blocking_save; // was stdio blocking at entry? restore on stop.
} notcurses; } notcurses;
typedef struct { typedef struct blitterargs {
int begy; // upper left start within visual int begy; // upper left start within visual
int begx; int begx;
int placey; // placement within ncplane int placey; // placement within ncplane
@ -1002,6 +1002,7 @@ sprite_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell){
s->n->tam[s->dimx * ycell + xcell].state = SPRIXCELL_TRANSPARENT; s->n->tam[s->dimx * ycell + xcell].state = SPRIXCELL_TRANSPARENT;
}else if(s->n->tam[s->dimx * ycell + xcell].state == SPRIXCELL_ANNIHILATED){ }else if(s->n->tam[s->dimx * ycell + xcell].state == SPRIXCELL_ANNIHILATED){
uint8_t* auxvec = s->n->tam[s->dimx * ycell + xcell].auxvector; uint8_t* auxvec = s->n->tam[s->dimx * ycell + xcell].auxvector;
assert(auxvec);
// sets the new state itself // sets the new state itself
ret = nc->tcache.pixel_rebuild(s, ycell, xcell, auxvec); ret = nc->tcache.pixel_rebuild(s, ycell, xcell, auxvec);
} }

View File

@ -205,7 +205,7 @@ kitty_null(char* triplet, int skip, int max, int pleft, uint8_t* auxvec){
static inline int static inline int
kitty_restore(char* triplet, int skip, int max, int pleft, kitty_restore(char* triplet, int skip, int max, int pleft,
const uint8_t* auxvec, sprixcell_e* state){ const uint8_t* auxvec, sprixcell_e* state){
//fprintf(stderr, "SKIP/MAX/PLEFT %d/%d/%d\n", skip, max, pleft); //fprintf(stderr, "SKIP/MAX/PLEFT %d/%d/%d auxvec %p\n", skip, max, pleft, auxvec);
if(pleft > 3){ if(pleft > 3){
pleft = 3; pleft = 3;
} }

View File

@ -269,6 +269,14 @@ void free_plane(ncplane* p){
if(p->sprite){ if(p->sprite){
sprixel_hide(p->sprite); sprixel_hide(p->sprite);
} }
if(p->tam){
for(int y = 0 ; y < p->leny ; ++y){
for(int x = 0 ; x < p->lenx ; ++x){
free(p->tam[y * p->lenx + x].auxvector);
p->tam[y * p->lenx + x].auxvector = NULL;
}
}
}
free(p->tam); free(p->tam);
egcpool_dump(&p->pool); egcpool_dump(&p->pool);
free(p->name); free(p->name);

View File

@ -86,12 +86,6 @@ void sprixel_hide(sprixel* s){
s->movedfromy = ncplane_abs_y(s->n); s->movedfromy = ncplane_abs_y(s->n);
s->movedfromx = ncplane_abs_x(s->n); s->movedfromx = ncplane_abs_x(s->n);
if(s->n){ if(s->n){
for(int y = 0 ; y < s->dimy ; ++y){
for(int x = 0 ; x < s->dimx ; ++x){
free(s->n->tam[y * s->dimx + x].auxvector);
s->n->tam[y * s->dimx + x].auxvector = NULL;
}
}
s->n->sprite = NULL; s->n->sprite = NULL;
s->n = NULL; s->n = NULL;
} }