From 6f1ab78793b3e8f299ddbdb867202a0bedd97688 Mon Sep 17 00:00:00 2001 From: dweller Date: Fri, 4 Apr 2025 17:46:48 +0300 Subject: fix iui_label buffer alloc; who needs va_copy anyways C89 FTW --- sources/iui.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sources') diff --git a/sources/iui.c b/sources/iui.c index 6f82ad1..4e656c6 100644 --- a/sources/iui.c +++ b/sources/iui.c @@ -148,10 +148,16 @@ void iui_label(iui* ui, u16 x, u16 y, int w, int h, char* fmt, ...) va_list ap = {0}; xctx* x11 = (xctx*)ui->usr; - buf = ar_push(ui->ar, 512); va_start(ap, fmt); - len = vsnprintf(buf, 511, fmt, ap); + len = vsnprintf(NULL, 0, fmt, ap); + va_end(ap); + + if(len) len++; + buf = ar_push(ui->ar, len); + + va_start(ap, fmt); + len = vsnprintf(buf, len, fmt, ap); va_end(ap); { -- cgit v1.2.3