summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-09-14 08:49:00 -0400
committerAndrew Opalach <andrew@akon.city> 2026-09-14 08:49:00 -0400
commit8386718d2b7e5af4e74544922197df678a761c5f (patch)
treef91ba1a168146b74bfe4963aebf9790179160804 /include
parenta35dc6bc6815b5ae077b9ce38e76bfd509c6cabc (diff)
downloadlibalabaster-8386718d2b7e5af4e74544922197df678a761c5f.tar.gz
libalabaster-8386718d2b7e5af4e74544922197df678a761c5f.tar.bz2
libalabaster-8386718d2b7e5af4e74544922197df678a761c5f.zip
wstr: Reserve by characters instead of bytesHEADmaster
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'include')
-rw-r--r--include/al/wstr.h6
1 files changed, 3 insertions, 3 deletions
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));