diff --git a/cucul/export_ansi.c b/cucul/export_ansi.c index c526105..db77ecc 100644 --- a/cucul/export_ansi.c +++ b/cucul/export_ansi.c @@ -99,7 +99,7 @@ void _cucul_get_ansi(cucul_t *qq, struct cucul_export *ex) } /* Crop to really used size */ - ex->size = strlen(ex->buffer) + 1; + ex->size = (uintptr_t)(cur - ex->buffer); ex->buffer = realloc(ex->buffer, ex->size); } diff --git a/cucul/export_html.c b/cucul/export_html.c index 67b293b..79a26a5 100644 --- a/cucul/export_html.c +++ b/cucul/export_html.c @@ -185,7 +185,7 @@ void _cucul_get_html3(cucul_t *qq, struct cucul_export *ex) cur += sprintf(cur, "\n"); /* Crop to really used size */ - ex->size = strlen(ex->buffer) + 1; + ex->size = (uintptr_t)(cur - ex->buffer); ex->buffer = realloc(ex->buffer, ex->size); } diff --git a/cucul/export_irc.c b/cucul/export_irc.c index 214ad3c..83eff3b 100644 --- a/cucul/export_irc.c +++ b/cucul/export_irc.c @@ -58,8 +58,6 @@ void _cucul_get_irc(cucul_t *qq, struct cucul_export *ex) cur = ex->buffer; - *cur++ = '\x0f'; - for(y = 0; y < qq->height; y++) { uint32_t *lineattr = qq->attr + y * qq->width; @@ -105,9 +103,7 @@ void _cucul_get_irc(cucul_t *qq, struct cucul_export *ex) *cur++ = '\n'; } - *cur++ = '\x0f'; - /* Crop to really used size */ - ex->size = strlen(ex->buffer) + 1; + ex->size = (uintptr_t)(cur - ex->buffer); ex->buffer = realloc(ex->buffer, ex->size); } diff --git a/cucul/export_ps.c b/cucul/export_ps.c index 21351cc..76632b3 100644 --- a/cucul/export_ps.c +++ b/cucul/export_ps.c @@ -134,7 +134,7 @@ void _cucul_get_ps(cucul_t *qq, struct cucul_export *ex) cur += sprintf(cur, "showpage\n"); /* Crop to really used size */ - ex->size = strlen(ex->buffer) + 1; + ex->size = (uintptr_t)(cur - ex->buffer); ex->buffer = realloc(ex->buffer, ex->size); } diff --git a/cucul/export_svg.c b/cucul/export_svg.c index 721b3d9..f0f0f4e 100644 --- a/cucul/export_svg.c +++ b/cucul/export_svg.c @@ -146,7 +146,7 @@ void _cucul_get_svg(cucul_t *qq, struct cucul_export *ex) cur += sprintf(cur, "\n"); /* Crop to really used size */ - ex->size = strlen(ex->buffer) + 1; + ex->size = (uintptr_t)(cur - ex->buffer); ex->buffer = realloc(ex->buffer, ex->size); }