diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2017-02-13 22:17:29 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2017-02-13 22:17:29 +0100 |
commit | 095714cb2d6409afeee0b1df82b4a543b961efcd (patch) | |
tree | 0c39a836be6cd7ee3134befb761f8fc4782865c4 /src | |
parent | 716cbb0627f1432bae86b2f3daa1261c0e907776 (diff) | |
download | blogc-095714cb2d6409afeee0b1df82b4a543b961efcd.tar.gz blogc-095714cb2d6409afeee0b1df82b4a543b961efcd.tar.bz2 blogc-095714cb2d6409afeee0b1df82b4a543b961efcd.zip |
blogc-make: fixed dirname calls, to work on freebsd
Diffstat (limited to 'src')
-rw-r--r-- | src/blogc-make/exec-native.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/blogc-make/exec-native.c b/src/blogc-make/exec-native.c index 8c49593..7997aa4 100644 --- a/src/blogc-make/exec-native.c +++ b/src/blogc-make/exec-native.c @@ -141,15 +141,14 @@ bm_exec_native_rm(const char *output_dir, bm_filectx_t *dest, bool verbose) int rv = 0; - char *short_path = bc_strdup(dest->short_path); - char *path = bc_strdup(dest->path); - - char *dir_short = dirname(short_path); - char *dir = dirname(path); + // blame freebsd's libc for all of those memory allocations around dirname + // calls! + char *short_dir = bc_strdup(dirname(dest->short_path)); + char *dir = bc_strdup(dirname(dest->path)); bc_error_t *err = NULL; - while ((0 != strcmp(dir_short, ".")) && (0 != strcmp(dir_short, "/"))) { + while ((0 != strcmp(short_dir, ".")) && (0 != strcmp(short_dir, "/"))) { bool empty = bm_exec_empty_dir(dir, &err); if (err != NULL) { fprintf(stderr, "blogc-make: error: %s\n", err->msg); @@ -175,12 +174,16 @@ bm_exec_native_rm(const char *output_dir, bm_filectx_t *dest, bool verbose) break; } - dir_short = dirname(dir_short); - dir = dirname(dir); + char *tmp = short_dir; + short_dir = bc_strdup(dirname(short_dir)); + free(tmp); + tmp = dir; + dir = bc_strdup(dirname(dir)); + free(tmp); } - free(short_path); - free(path); + free(short_dir); + free(dir); return rv; } |