diff --git a/src/lib/internal.h b/src/lib/internal.h index ff104ad87..d70d38e73 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -755,7 +755,7 @@ void sprixel_free(sprixel* s); void sprixel_invalidate(sprixel* s); void sprixel_hide(sprixel* s); // dimy and dimx are cell geometry, not pixel -sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int placey, int placex, +sprixel* sprixel_create(ncplane* n, char* s, int bytes, int placey, int placex, int sprixelid, int dimy, int dimx, int pixy, int pixx, int parse_start, int* tacache); API int sprite_wipe_cell(const notcurses* nc, sprixel* s, int y, int x); @@ -1160,7 +1160,7 @@ egc_rtl(const char* egc, int* bytes){ // a reference to the context-wide sprixel cache. this ought be an entirely // new, purpose-specific plane. static inline int -plane_blit_sixel(ncplane* n, const char* s, int bytes, int placey, int placex, +plane_blit_sixel(ncplane* n, char* s, int bytes, int placey, int placex, int leny, int lenx, int sprixelid, int dimy, int dimx, int parse_start, int* tacache){ sprixel* spx = sprixel_create(n, s, bytes, placey, placex, sprixelid, diff --git a/src/lib/kitty.c b/src/lib/kitty.c index b19e19978..b82b8e1df 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -303,6 +303,7 @@ int kitty_blit(ncplane* nc, int linesize, const void* data, free(buf); return -1; } + // takes ownership of |buf| on success if(plane_blit_sixel(nc, buf, size, bargs->placey, bargs->placex, rows, cols, bargs->u.pixel.sprixelid, leny, lenx, parse_start, tacache) < 0){ @@ -310,7 +311,6 @@ int kitty_blit(ncplane* nc, int linesize, const void* data, free(buf); return -1; } - free(buf); return 1; } diff --git a/src/lib/sixel.c b/src/lib/sixel.c index 7aeeaa194..8ee4704cf 100644 --- a/src/lib/sixel.c +++ b/src/lib/sixel.c @@ -507,6 +507,7 @@ int sixel_blit_inner(ncplane* nc, int leny, int lenx, sixeltable* stab, free(buf); return -1; } + // takes ownership of |buf| on success if(plane_blit_sixel(nc, buf, size, bargs->placey, bargs->placex, rows, cols, bargs->u.pixel.sprixelid, leny, lenx, parse_start, tacache) < 0){ @@ -514,7 +515,6 @@ int sixel_blit_inner(ncplane* nc, int leny, int lenx, sixeltable* stab, free(buf); return -1; } - free(buf); return 1; } diff --git a/src/lib/sprite.c b/src/lib/sprite.c index 1da12574d..84637fedc 100644 --- a/src/lib/sprite.c +++ b/src/lib/sprite.c @@ -30,15 +30,12 @@ sprixel* sprixel_by_id(notcurses* nc, uint32_t id){ } // y and x are the cell geometry, not the pixel geometry -sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int placey, int placex, +sprixel* sprixel_create(ncplane* n, char* s, int bytes, int placey, int placex, int sprixelid, int dimy, int dimx, int pixy, int pixx, int parse_start, int* tacache){ sprixel* ret = malloc(sizeof(sprixel)); if(ret){ - if((ret->glyph = memdup(s, bytes + 1)) == NULL){ - free(ret); - return NULL; - } + ret->glyph = s; ret->glyphlen = bytes; ret->tacache = tacache; ret->invalidated = SPRIXEL_INVALIDATED;