aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-17 20:58:36 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-23 08:40:22 +0000
commit8c44b63938684cbd485fec9965f15f1146e32081 (patch)
treeedf717f3b53d79f4ef208932457df59c5a7e918a
parentsixel: implement private mode 1070 - private color palette (diff)
sixel: free private color registers on unhook
-rw-r--r--sixel.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/sixel.c b/sixel.c
index dede6e10..63ce493b 100644
--- a/sixel.c
+++ b/sixel.c
@@ -50,17 +50,9 @@ sixel_init(struct terminal *term)
/* TODO: default palette */
if (term->sixel.use_private_palette) {
- if (term->sixel.private_palette == NULL) {
- term->sixel.private_palette = xcalloc(
- term->sixel.palette_size, sizeof(term->sixel.private_palette[0]));
- } else {
- /* Private palette - i.e. each sixel starts with a clean palette */
- memset(
- term->sixel.private_palette,
- 0,
- term->sixel.palette_size * sizeof(term->sixel.private_palette[0]));
- }
-
+ xassert(term->sixel.private_palette == NULL);
+ term->sixel.private_palette = xcalloc(
+ term->sixel.palette_size, sizeof(term->sixel.private_palette[0]));
term->sixel.palette = term->sixel.private_palette;
} else {
if (term->sixel.shared_palette == NULL) {
@@ -794,6 +786,9 @@ sixel_unhook(struct terminal *term)
term->sixel.max_col = 0;
term->sixel.pos = (struct coord){0, 0};
+ free(term->sixel.private_palette);
+ term->sixel.private_palette = NULL;
+
LOG_DBG("you now have %zu sixels in current grid",
tll_length(term->grid->sixel_images));