diff options
author | Michael Vetter <jubalh@iodoru.org> | 2021-03-30 17:38:13 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2021-03-30 17:38:13 +0200 |
commit | 1ec606540eb0f474f3d968d3566a7c56d778a367 (patch) | |
tree | bfe33ebccfc5f2e020a2bcf4908edbbfcc5791f4 /src/common.c | |
parent | 3c1e4bac3ae640bc4c451d7d4a1c06146e13a15a (diff) | |
download | profani-tty-1ec606540eb0f474f3d968d3566a7c56d778a367.tar.gz |
Get rid of asprintf and _GNU_SOURCE define
_GNU_SOURCE was even in some files where it was not needed at all (http*). Let's replace asprintf() with g_strdup_printf().
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/common.c b/src/common.c index 6defa7c1..eca444e6 100644 --- a/src/common.c +++ b/src/common.c @@ -34,8 +34,6 @@ * */ -#define _GNU_SOURCE 1 - #include "config.h" #include <errno.h> @@ -529,13 +527,14 @@ _unique_filename(const char* filename) unsigned int i = 0; while (g_file_test(unique, G_FILE_TEST_EXISTS)) { - free(unique); + g_free(unique); if (i > 1000) { // Give up after 1000 attempts. return NULL; } - if (asprintf(&unique, "%s.%u", filename, i) < 0) { + unique = g_strdup_printf("%s.%u", filename, i); + if (!unique) { return NULL; } |