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().
This commit is contained in:
Michael Vetter
2021-03-30 17:38:13 +02:00
parent 3c1e4bac3a
commit 1ec606540e
12 changed files with 97 additions and 104 deletions

View File

@@ -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;
}