From 8386718d2b7e5af4e74544922197df678a761c5f Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Mon, 14 Sep 2026 08:49:00 -0400 Subject: wstr: Reserve by characters instead of bytes Signed-off-by: Andrew Opalach --- include/al/wstr.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/al/wstr.h') diff --git a/include/al/wstr.h b/include/al/wstr.h index 4c37453..d62a4af 100644 --- a/include/al/wstr.h +++ b/include/al/wstr.h @@ -58,7 +58,7 @@ static inline void al_wstr_free(wstr *w) static inline u32 al_wstr_reserve(wstr *w, u32 size) { - return al_growing_allocation((void **)&w->data, w->alloc, size, al_realloc); + return al_growing_allocation((void **)&w->data, w->alloc, size * sizeof(wchar_t), al_realloc); } static inline void al_wstr_sized(wstr *w, u32 size) @@ -131,7 +131,7 @@ static inline bool al_str_from_wstr(str *s, wstr *w) static inline void al_wstr_cat(wstr *w, wstr *c) { - w->alloc = al_wstr_reserve(w, ((w->length + c->length) + 1) * sizeof(wchar_t)); + w->alloc = al_wstr_reserve(w, w->length + c->length + 1); al_memcpy(w->data + w->length, c->data, c->length * sizeof(wchar_t)); w->length += c->length; w->data[w->length] = L'\0'; @@ -139,7 +139,7 @@ static inline void al_wstr_cat(wstr *w, wstr *c) static inline void al_wstr_insert(wstr *w, u32 index, wstr *c) { - w->alloc = al_wstr_reserve(w, ((w->length + c->length) + 1) * sizeof(wchar_t)); + w->alloc = al_wstr_reserve(w, w->length + c->length + 1); wchar_t *pos = w->data + index; if (index < w->length) { al_memmove(pos + c->length, pos, (w->length - index) * sizeof(wchar_t)); -- cgit v1.2.3-101-g0448