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/path.c | |
parent | b240374c23365e33727d78ca74e901bcb383e077 (diff) | |
parent | 013e1c111e0717f6dc01a8e8582e13a4095e05bc (diff) |
Merge pull request #7 from omnisci3nce/transform-hierarchy
Transform hierarchy
Diffstat (limited to 'src/platform/path.c')
-rw-r--r-- | src/platform/path.c | 9 |
1 files changed, 7 insertions, 2 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 |