diff options
Diffstat (limited to 'src/std/str.c')
-rw-r--r-- | src/std/str.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/std/str.c b/src/std/str.c index 2aac15f..89c76a0 100644 --- a/src/std/str.c +++ b/src/std/str.c @@ -1,6 +1,7 @@ #include "str.h" #include <assert.h> #include <string.h> +#include "log.h" #include "mem.h" Str8 Str8_create(u8* buf, size_t len) { return (Str8){ .buf = buf, .len = len }; } @@ -33,6 +34,15 @@ char* Str8_to_cstr(arena* a, Str8 s) { return (char*)dest; } +char* Clone_cstr(arena* a, const char* s) { + if (s == NULL) { + WARN("Tried to clone a NULL char*"); + return NULL; + } + Str8 st = Str8_cstr_view(s); + return Str8_to_cstr(a, st); +} + Str8 Str8_concat(arena* a, Str8 left, Str8 right) { size_t n_bytes = left.len + right.len + 1; |