From a94640e71da088f8e7d9971ebe0681c08406df7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Mon, 27 Jul 2026 19:48:10 +0200 Subject: [PATCH] Fix str_push --- src/string.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/string.c b/src/string.c index 9737253..8e0ce2e 100644 --- a/src/string.c +++ b/src/string.c @@ -31,15 +31,12 @@ Str str_concat(Allocator *alloc, Str first, Str second) Str str_push(Allocator *alloc, Str str) { - U8 *mem = (U8 *)allocator_push(alloc, sizeof(Str) + str.len, alignof(Str)); - Str *new_str = (Str *)mem; - new_str->len = str.len; - new_str->str = &mem[sizeof(Str)]; + U8 *mem = (U8 *)allocator_push(alloc, str.len, 1); if (!str_is_empty(str)) { - MemCopy(new_str->str, str.str, str.len); + MemCopy(mem, str.str, str.len); } - return *new_str; + return str_create(mem, str.len); } static INLINE bool char_is_ascii_whitespace(U8 byte) @@ -85,6 +82,7 @@ Str str_ascii_trim(Str str) S64 str_substr(Str haystack, Str to_find) { + return -1; } // split @str on any byte in @separators, place split strings in @vec