Debian Codegraph @

src/basic/stdio-util.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "alloc-util.h"
4 #include "stdio-util.h"
5
6 char* asprintf_safe(const char *restrict fmt, ...) {
7 _cleanup_free_ char *buf = NULL;
8 va_list ap;
9 int r;
10
11 va_start(ap, fmt);
12 r = vasprintf(&buf, fmt, ap);
13 va_end(ap);
14
15 if (r < 0)
16 return NULL;
17 return TAKE_PTR(buf);
18 }