Fix str_push
This commit is contained in:
+4
-6
@@ -31,15 +31,12 @@ Str str_concat(Allocator *alloc, Str first, Str second)
|
|||||||
|
|
||||||
Str str_push(Allocator *alloc, Str str)
|
Str str_push(Allocator *alloc, Str str)
|
||||||
{
|
{
|
||||||
U8 *mem = (U8 *)allocator_push(alloc, sizeof(Str) + str.len, alignof(Str));
|
U8 *mem = (U8 *)allocator_push(alloc, str.len, 1);
|
||||||
Str *new_str = (Str *)mem;
|
|
||||||
new_str->len = str.len;
|
|
||||||
new_str->str = &mem[sizeof(Str)];
|
|
||||||
if (!str_is_empty(str)) {
|
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)
|
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)
|
S64 str_substr(Str haystack, Str to_find)
|
||||||
{
|
{
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// split @str on any byte in @separators, place split strings in @vec
|
// split @str on any byte in @separators, place split strings in @vec
|
||||||
|
|||||||
Reference in New Issue
Block a user