Define POSIX macro to have strdup

98c38dc6d6
sets C99 as standard.

strdup() is not part of C99.

For now set `-D_POSIX_C_SOURCE=200809L` macro to have strdup() in C99.
Using `gnu99` instead would be another option.

We should take more care to use glib functions whenever possible.

Regards https://github.com/profanity-im/profanity/issues/1357
This commit is contained in:
Michael Vetter
2020-06-12 16:12:21 +02:00
parent f1141932fc
commit 74e061165a
8 changed files with 28 additions and 25 deletions

View File

@@ -67,7 +67,7 @@
#define INPBLOCK_DEFAULT 1000
static char *prefs_loc;
static gchar *prefs_loc;
static GKeyFile *prefs;
gint log_maxsize = 0;
@@ -209,7 +209,7 @@ prefs_load(char *config_file)
if (config_file == NULL) {
prefs_loc = files_get_config_path(FILE_PROFRC);
} else {
prefs_loc = strdup(config_file);
prefs_loc = g_strdup(config_file);
}
if (g_file_test(prefs_loc, G_FILE_TEST_EXISTS)) {
@@ -236,7 +236,7 @@ prefs_close(void)
g_key_file_free(prefs);
prefs = NULL;
free(prefs_loc);
g_free(prefs_loc);
prefs_loc = NULL;
}