diff options
author | Joshua Rowe <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-20 18:33:05 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-20 18:33:05 +1000 |
commit | b283835c5e6998bda9b986ff49ee4fd57fe68fc7 (patch) | |
tree | be478c168506a669876ff9df8920b7e35539e98f /src/platform | |
parent | b240374c23365e33727d78ca74e901bcb383e077 (diff) | |
parent | 013e1c111e0717f6dc01a8e8582e13a4095e05bc (diff) |
Merge pull request #7 from omnisci3nce/transform-hierarchy
Transform hierarchy
Diffstat (limited to 'src/platform')
-rw-r--r-- | src/platform/path.c | 9 | ||||
-rw-r--r-- | src/platform/path.h | 2 |
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 |