summaryrefslogtreecommitdiff
path: root/src/platform
diff options
context:
space:
mode:
authorOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-17 15:01:54 +1100
committerOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-17 15:01:54 +1100
commitc97327fcdcbe8b85d7718cfb722e1525986a8514 (patch)
tree9c0df938345bff356f8fcc97740afedb1f500b3d /src/platform
parent1afe4876cb8133c5b47fdcfeb07decc5565c4844 (diff)
parent51b4a3fc75351d6ecd2142c228d31a1f7ed52152 (diff)
Merge branch 'master' into transform-hierarchy
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/path.c9
-rw-r--r--src/platform/path.h2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/platform/path.c b/src/platform/path.c
index e67102b..9572941 100644
--- a/src/platform/path.c
+++ b/src/platform/path.c
@@ -1,12 +1,17 @@
#include "path.h"
#include <libgen.h>
+#include <stdlib.h>
#include <string.h>
+#include "mem.h"
#include "str.h"
#if defined(CEL_PLATFORM_LINUX) || defined(CEL_PLATFORM_MAC)
-path_opt path_parent(const char* path) {
- char* path_dirname = dirname(path);
+path_opt path_parent(arena* a, const char* path) {
+ // Duplicate the string because dirname doesnt like const literals
+ char* path_copy = arena_alloc(a, strlen(path) + 1);
+ strcpy(path_copy, path);
+ char* path_dirname = dirname(path_copy);
return (path_opt){ .path = str8_cstr_view(path_dirname), .has_value = true };
}
#endif
diff --git a/src/platform/path.h b/src/platform/path.h
index 0ec6993..73063ea 100644
--- a/src/platform/path.h
+++ b/src/platform/path.h
@@ -13,4 +13,4 @@ typedef struct path_opt {
bool has_value;
} path_opt;
-path_opt path_parent(const char* path); // TODO: convert to using str8 \ No newline at end of file
+path_opt path_parent(arena* a, const char* path); // TODO: convert to using str8 \ No newline at end of file