t/nvmept_trim: increase transfer size for some tests
[fio.git] / oslib / asprintf.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "oslib/asprintf.h"
4
5 #ifndef CONFIG_HAVE_VASPRINTF
6 int vasprintf(char **strp, const char *fmt, va_list ap)
7 {
8         va_list ap_copy;
9         char *str;
10         int len;
11
12 #ifdef va_copy
13         va_copy(ap_copy, ap);
14 #else
15         __va_copy(ap_copy, ap);
16 #endif
17         len = vsnprintf(NULL, 0, fmt, ap_copy);
18         va_end(ap_copy);
19
20         if (len < 0)
21                 return len;
22
23         len++;
24         str = malloc(len);
25         *strp = str;
26         return str ? vsnprintf(str, len, fmt, ap) : -1;
27 }
28 #endif
29
30 #ifndef CONFIG_HAVE_ASPRINTF
31 int asprintf(char **strp, const char *fmt, ...)
32 {
33         va_list arg;
34         int done;
35
36         va_start(arg, fmt);
37         done = vasprintf(strp, fmt, arg);
38         va_end(arg);
39
40         return done;
41 }
42 #endif