From 9c472a5d5efc1e621a656fe5fcc0376df630170e Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 27 Apr 2021 21:17:12 -0400 Subject: [PATCH] free auxvectors at ncplane free time, not sixel hide time #1440 --- src/lib/internal.h | 3 ++- src/lib/kitty.c | 2 +- src/lib/notcurses.c | 8 ++++++++ src/lib/sprite.c | 6 ------ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/internal.h b/src/lib/internal.h index 558f92cbf..a6a9f8809 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -617,7 +617,7 @@ typedef struct notcurses { unsigned stdio_blocking_save; // was stdio blocking at entry? restore on stop. } notcurses; -typedef struct { +typedef struct blitterargs { int begy; // upper left start within visual int begx; 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; }else if(s->n->tam[s->dimx * ycell + xcell].state == SPRIXCELL_ANNIHILATED){ uint8_t* auxvec = s->n->tam[s->dimx * ycell + xcell].auxvector; + assert(auxvec); // sets the new state itself ret = nc->tcache.pixel_rebuild(s, ycell, xcell, auxvec); } diff --git a/src/lib/kitty.c b/src/lib/kitty.c index 43a380571..53fda7aba 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -205,7 +205,7 @@ kitty_null(char* triplet, int skip, int max, int pleft, uint8_t* auxvec){ static inline int kitty_restore(char* triplet, int skip, int max, int pleft, 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){ pleft = 3; } diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 41277c2ad..0be6dd852 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -269,6 +269,14 @@ void free_plane(ncplane* p){ if(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); egcpool_dump(&p->pool); free(p->name); diff --git a/src/lib/sprite.c b/src/lib/sprite.c index 139b4e456..4331bfea1 100644 --- a/src/lib/sprite.c +++ b/src/lib/sprite.c @@ -86,12 +86,6 @@ void sprixel_hide(sprixel* s){ s->movedfromy = ncplane_abs_y(s->n); s->movedfromx = ncplane_abs_x(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 = NULL; }