auxvec: unite memory release in sprite_rebuild() #1440

This commit is contained in:
nick black 2021-04-29 06:44:19 -04:00 committed by Nick Black
parent a6766c3bd4
commit 069084d435
2 changed files with 3 additions and 4 deletions

View File

@ -1001,15 +1001,15 @@ sprite_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell){
int ret = 0;
// special case the transition back to SPRIXCELL_TRANSPARENT; this can be
// done in O(1), since the actual glyph needn't change.
uint8_t* auxvec = s->n->tam[s->dimx * ycell + xcell].auxvector;
assert(auxvec);
if(s->n->tam[s->dimx * ycell + xcell].state == SPRIXCELL_ANNIHILATED_TRANS){
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);
free(auxvec);
}
free(auxvec);
s->n->tam[s->dimx * ycell + xcell].auxvector = NULL;
return ret;
}

View File

@ -314,7 +314,6 @@ int kitty_rebuild(sprixel* s, int ycell, int xcell, uint8_t* auxvec){
//fprintf(stderr, "CLEARED ROW, TARGY: %d\n", targy - 1);
if(--targy == 0){
s->n->tam[s->dimx * ycell + xcell].state = state;
free(auxvec);
return 0;
}
thisrow = targx;