From 6743bc18fd577b6027d9cb1bdfe4bc57903ccfea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Sat, 10 Feb 2024 22:36:04 +0100 Subject: [PATCH] font: optimise font_wrap --- engine/joint/v4k.h | 3 +-- engine/split/v4k_font.c | 3 +-- engine/v4k.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index d4d1de1..dbfb45a 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -363852,11 +363852,10 @@ const char *font_wrap(const char *text, float max_width) { array(char*) words = strsplit(text, " "); static __thread int slot = 0; - static __thread char *buf[16] = {0}; + static __thread char *buf[16][FONT_MAX_STRING_LEN] = {0}; int len = strlen(text) + array_count(words); slot = (slot+1) % 16; - buf[slot] = REALLOC(buf[slot], len+1); memset(buf[slot], 0, len+1); char *out = buf[slot]; diff --git a/engine/split/v4k_font.c b/engine/split/v4k_font.c index f6d97e7..72eff70 100644 --- a/engine/split/v4k_font.c +++ b/engine/split/v4k_font.c @@ -2295,11 +2295,10 @@ const char *font_wrap(const char *text, float max_width) { array(char*) words = strsplit(text, " "); static __thread int slot = 0; - static __thread char *buf[16] = {0}; + static __thread char *buf[16][FONT_MAX_STRING_LEN] = {0}; int len = strlen(text) + array_count(words); slot = (slot+1) % 16; - buf[slot] = REALLOC(buf[slot], len+1); memset(buf[slot], 0, len+1); char *out = buf[slot]; diff --git a/engine/v4k.c b/engine/v4k.c index 5df5a75..973630b 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -10993,11 +10993,10 @@ const char *font_wrap(const char *text, float max_width) { array(char*) words = strsplit(text, " "); static __thread int slot = 0; - static __thread char *buf[16] = {0}; + static __thread char *buf[16][FONT_MAX_STRING_LEN] = {0}; int len = strlen(text) + array_count(words); slot = (slot+1) % 16; - buf[slot] = REALLOC(buf[slot], len+1); memset(buf[slot], 0, len+1); char *out = buf[slot];