aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jalv.c11
-rw-r--r--src/jalv_console.c6
-rw-r--r--src/jalv_internal.h11
-rw-r--r--src/persist.c4
4 files changed, 18 insertions, 14 deletions
diff --git a/src/jalv.c b/src/jalv.c
index a53409b..e927ee2 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -14,8 +14,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define _XOPEN_SOURCE 500
-
#include <math.h>
#include <signal.h>
#include <stdbool.h>
@@ -389,14 +387,13 @@ jack_session_cb(jack_session_event_t* event, void* arg)
{
Jalv* host = (Jalv*)arg;
- char cmd[256];
- snprintf(cmd, sizeof(cmd), "%s -u %s -l '%s'",
+ #define MAX_CMD_LEN 256
+ event->command_line = malloc(MAX_CMD_LEN);
+ snprintf(event->command_line, MAX_CMD_LEN, "%s -u %s -l '%s'",
host->prog_name,
event->client_uuid,
event->session_dir);
- event->command_line = strdup(cmd);
-
switch (event->type) {
case JackSessionSave:
case JackSessionSaveTemplate:
@@ -563,7 +560,7 @@ main(int argc, char** argv)
jack_name = calloc(jack_client_name_size(), sizeof(char));
strncpy(jack_name, name_str, jack_client_name_size() - 1);
} else {
- jack_name = strdup(name_str);
+ jack_name = jalv_strdup(name_str);
}
/* Connect to JACK */
diff --git a/src/jalv_console.c b/src/jalv_console.c
index 29ac146..94881ab 100644
--- a/src/jalv_console.c
+++ b/src/jalv_console.c
@@ -14,8 +14,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define _XOPEN_SOURCE 500
-
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
@@ -53,13 +51,13 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts)
fprintf(stderr, "Missing argument for -u\n");
return 1;
}
- opts->uuid = strdup((*argv)[a]);
+ opts->uuid = jalv_strdup((*argv)[a]);
} else if ((*argv)[a][1] == 'l') {
if (++a == *argc) {
fprintf(stderr, "Missing argument for -l\n");
return 1;
}
- opts->load = strdup((*argv)[a]);
+ opts->load = jalv_strdup((*argv)[a]);
} else {
fprintf(stderr, "Unknown option %s\n", (*argv)[a]);
return print_usage((*argv)[0], true);
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 3eb1a3d..c171b72 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -18,6 +18,8 @@
#define JALV_INTERNAL_H
#include <semaphore.h>
+#include <stdlib.h>
+#include <string.h>
#include <jack/jack.h>
#include <jack/ringbuffer.h>
@@ -138,6 +140,15 @@ jalv_restore(Jalv* jalv, const char* dir);
void
jalv_restore_instance(Jalv* jalv, const char* dir);
+static inline char*
+jalv_strdup(const char* str)
+{
+ const size_t len = strlen(str);
+ char* copy = (char*)malloc(len + 1);
+ memcpy(copy, str, len + 1);
+ return copy;
+}
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/src/persist.c b/src/persist.c
index 384dd4b..d4ce803 100644
--- a/src/persist.c
+++ b/src/persist.c
@@ -14,8 +14,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define _XOPEN_SOURCE 500
-
#include <assert.h>
#include <locale.h>
#include <stdio.h>
@@ -115,7 +113,7 @@ jalv_save(Jalv* jalv, const char* dir)
assert(!jalv->writer);
// Set numeric locale to C so snprintf %f is Turtle compatible
- char* locale = strdup(setlocale(LC_NUMERIC, NULL));
+ char* locale = jalv_strdup(setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
const size_t dir_len = strlen(dir);