X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsystem%2Fs.h;h=688af2d1939effe22e6b3df574492956a012cda0;hb=bf5d08c21beb3a37bbee2c849268b2b0d5a7f708;hp=2b3c3566524b277d7072010715648a9b04361550;hpb=755798450bd0ed6ca319021e4e98bafc64b270cd;p=nothing.git diff --git a/src/system/s.h b/src/system/s.h index 2b3c3566..688af2d1 100644 --- a/src/system/s.h +++ b/src/system/s.h @@ -1,8 +1,10 @@ #ifndef S_H_ #define S_H_ +#include #include #include "system/stacktrace.h" +#include "system/memory.h" typedef struct { size_t count; @@ -106,4 +108,15 @@ String chop_word(String *input) return result; } +static inline +char *string_to_cstr(Memory *memory, String s) +{ + trace_assert(memory); + + char *result = memory_alloc(memory, s.count + 1); + memset(result, 0, s.count + 1); + memcpy(result, s.data, s.count); + return result; +} + #endif // S_H_