]> git.lizzy.rs Git - nothing.git/blobdiff - src/system/s.h
Try to remove malloc from LevelEditor
[nothing.git] / src / system / s.h
index 43ff261cdf590ceb86b306d0c67926b483187ff0..aa7b4b401ccd6e7ed2083982322aaefe1fde7a7a 100644 (file)
@@ -120,4 +120,16 @@ char *string_to_cstr(Memory *memory, String s)
     return result;
 }
 
+static inline
+char *strdup_to_memory(Memory *memory, const char *s)
+{
+    trace_assert(memory);
+    trace_assert(s);
+
+    const size_t n = strlen(s) + 1;
+    char *d = memory_alloc(memory, n);
+    memcpy(d, s, n);
+    return d;
+}
+
 #endif  // S_H_