diff --git a/src/figlet.c b/src/figlet.c index 511f70d..6c8356a 100644 --- a/src/figlet.c +++ b/src/figlet.c @@ -43,10 +43,6 @@ int init_figlet(context_t *cx) if(open_font(cx)) return -1; - cx->x = cx->y = 0; - cx->w = cx->h = 0; - cx->cv = cucul_create_canvas(1, 1); - cx->feed = feed_figlet; cx->flush = flush_figlet; cx->end = end_figlet; @@ -125,7 +121,6 @@ static int flush_figlet(context_t *cx) static int end_figlet(context_t *cx) { cucul_free_canvas(cx->image); - cucul_free_canvas(cx->cv); free(cx->lookup); return 0; diff --git a/src/mono9.c b/src/mono9.c index 5db7dff..11d76b2 100644 --- a/src/mono9.c +++ b/src/mono9.c @@ -41,10 +41,6 @@ int init_big(context_t *cx) cx->onechar = cucul_create_canvas(1, 1); cucul_set_color(cx->onechar, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK); - cx->x = cx->y = 0; - cx->w = cx->h = 0; - cx->cv = cucul_create_canvas(1, 1); - cx->feed = feed_big; cx->flush = flush_big; cx->end = end_big; @@ -127,7 +123,6 @@ static int flush_big(context_t *cx) static int end_big(context_t *cx) { cucul_free_canvas(cx->onechar); - cucul_free_canvas(cx->cv); free(cx->buf); cucul_free_font(cx->f); diff --git a/src/render.c b/src/render.c index cb4dc56..8763099 100644 --- a/src/render.c +++ b/src/render.c @@ -31,6 +31,11 @@ int render_init(context_t *cx) { + cx->x = cx->y = 0; + cx->w = cx->h = 0; + cx->lines = 0; + cx->cv = cucul_create_canvas(0, 0); + if(!strcasecmp(cx->font, "mono9")) return init_big(cx); @@ -114,6 +119,7 @@ int render_line(context_t *cx) int render_end(context_t *cx) { cx->end(cx); + cucul_free_canvas(cx->cv); return 0; } diff --git a/src/term.c b/src/term.c index 1859c01..9896277 100644 --- a/src/term.c +++ b/src/term.c @@ -34,9 +34,6 @@ int init_tiny(context_t *cx) { cx->ew = 16; cx->eh = 2; - cx->x = cx->y = 0; - cx->w = cx->h = 0; - cx->cv = cucul_create_canvas(cx->ew, cx->eh); cx->feed = feed_tiny; cx->flush = flush_tiny; @@ -106,8 +103,6 @@ static int flush_tiny(context_t *cx) static int end_tiny(context_t *cx) { - cucul_free_canvas(cx->cv); - return 0; } diff --git a/src/toilet.h b/src/toilet.h index 017c375..ea1c3c3 100644 --- a/src/toilet.h +++ b/src/toilet.h @@ -25,7 +25,7 @@ struct toilet_context cucul_canvas_t *cv; cucul_canvas_t *torender; - unsigned int w, h, ew, eh, x, y; + unsigned int w, h, ew, eh, x, y, lines; /* Render methods */ int (*feed)(struct toilet_context *, uint32_t);