Fix str_push

This commit is contained in:
2026-07-27 19:48:10 +02:00
parent bd008c51fe
commit a94640e71d
+4 -6
View File
@@ -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