aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-11-25 19:54:46 -0500
committerDavid Robillard <d@drobilla.net>2024-12-02 19:24:57 -0500
commit15001976b55519d299341a79431aea2bf2aafdb3 (patch)
treee1e58d3c3e99325894be880c14718a4685cb3639
parent2de7788dcff3de47b6c60da2d40ff9bce72b5774 (diff)
downloadjalv-15001976b55519d299341a79431aea2bf2aafdb3.tar.gz
jalv-15001976b55519d299341a79431aea2bf2aafdb3.tar.bz2
jalv-15001976b55519d299341a79431aea2bf2aafdb3.zip
Replace jalv_strjoin() with use of zix_path_join()
-rw-r--r--src/jalv.c3
-rw-r--r--src/state.c7
-rw-r--r--src/string_utils.c14
-rw-r--r--src/string_utils.h4
4 files changed, 6 insertions, 22 deletions
diff --git a/src/jalv.c b/src/jalv.c
index 0cced8f..63351e3 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -41,6 +41,7 @@
#include <lv2/worker/worker.h>
#include <zix/allocator.h>
#include <zix/filesystem.h>
+#include <zix/path.h>
#include <zix/ring.h>
#include <zix/sem.h>
#include <zix/status.h>
@@ -672,7 +673,7 @@ initial_state(LilvWorld* const world,
LilvState* state = NULL;
if (state_path) {
if (zix_file_type(state_path) == ZIX_FILE_TYPE_DIRECTORY) {
- char* const path = jalv_strjoin(state_path, "/state.ttl");
+ char* const path = zix_path_join(NULL, state_path, "state.ttl");
state = lilv_state_new_from_file(world, urid_map, NULL, path);
free(path);
} else {
diff --git a/src/state.c b/src/state.c
index 85b85bd..1b79b34 100644
--- a/src/state.c
+++ b/src/state.c
@@ -9,7 +9,6 @@
#include "mapper.h"
#include "port.h"
#include "process.h"
-#include "string_utils.h"
#include "types.h"
#include <lilv/lilv.h>
@@ -17,6 +16,7 @@
#include <lv2/state/state.h>
#include <lv2/urid/urid.h>
#include <zix/attributes.h>
+#include <zix/path.h>
#include <zix/ring.h>
#include <zix/sem.h>
#include <zix/status.h>
@@ -32,7 +32,8 @@ jalv_make_path(LV2_State_Make_Path_Handle handle, const char* path)
Jalv* jalv = (Jalv*)handle;
// Create in save directory if saving, otherwise use temp directory
- return jalv_strjoin(jalv->save_dir ? jalv->save_dir : jalv->temp_dir, path);
+ const char* const dir = jalv->save_dir ? jalv->save_dir : jalv->temp_dir;
+ return zix_path_join(NULL, dir, path);
}
static const void*
@@ -58,7 +59,7 @@ jalv_save(Jalv* jalv, const char* dir)
LV2_URID_Map* const map = jalv_mapper_urid_map(jalv->mapper);
LV2_URID_Unmap* const unmap = jalv_mapper_urid_unmap(jalv->mapper);
- jalv->save_dir = jalv_strjoin(dir, "/");
+ jalv->save_dir = zix_path_join(NULL, dir, NULL);
LilvState* const state =
lilv_state_new_from_instance(jalv->plugin,
diff --git a/src/string_utils.c b/src/string_utils.c
index a690eb1..dcabcac 100644
--- a/src/string_utils.c
+++ b/src/string_utils.c
@@ -14,17 +14,3 @@ jalv_strdup(const char* const str)
memcpy(copy, str, len + 1);
return copy;
}
-
-char*
-jalv_strjoin(const char* const a, const char* const b)
-{
- const size_t a_len = strlen(a);
- const size_t b_len = strlen(b);
- char* const out = (char*)malloc(a_len + b_len + 1);
-
- memcpy(out, a, a_len);
- memcpy(out + a_len, b, b_len);
- out[a_len + b_len] = '\0';
-
- return out;
-}
diff --git a/src/string_utils.h b/src/string_utils.h
index d99e10e..74193a0 100644
--- a/src/string_utils.h
+++ b/src/string_utils.h
@@ -13,10 +13,6 @@ JALV_BEGIN_DECLS
char*
jalv_strdup(const char* str);
-/// Return a newly allocated concatenation of two strings
-char*
-jalv_strjoin(const char* a, const char* b);
-
JALV_END_DECLS
#endif // JALV_STRING_UTILS_H