]> git.lizzy.rs Git - nothing.git/blobdiff - src/system/s.h
Implement chop_player_layer
[nothing.git] / src / system / s.h
index 2b3c3566524b277d7072010715648a9b04361550..688af2d1939effe22e6b3df574492956a012cda0 100644 (file)
@@ -1,8 +1,10 @@
 #ifndef S_H_
 #define S_H_
 
+#include <stdlib.h>
 #include <string.h>
 #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_