Go to the source code of this file.
◆ ANN2() [1/2]
Definition at line 3 of file gwion_print.c.
3 {
4 va_list tmpa;
5 va_copy(tmpa, args);
6 const int size = vsnprintf(NULL, 0,
fmt, tmpa);
7 va_end(tmpa);
8 return size;
9}
◆ ANN2() [2/2]
Definition at line 29 of file gwion_print.c.
29 {
30 va_list args;
33 va_end(args);
34 return ret;
35}
static int gw_vasprintf(MemPool mp, char **str, const char *fmt, va_list args)
◆ gw_vasprintf()
static int gw_vasprintf |
( |
MemPool | mp, |
|
|
char ** | str, |
|
|
const char * | fmt, |
|
|
va_list | args ) |
|
static |
Definition at line 12 of file gwion_print.c.
12 {
14 const size_t base_len = base ? strlen(base) : 0;
15 const int size = fmtlen(
fmt, args);
16 if (size < 0) return -1;
17 char *ret =
mp_malloc2(mp, base_len + size + 1);
18 if (base) strcpy(ret, base);
19 const int final_len = vsprintf(ret + base_len,
fmt, args);
20 if (final_len < 0) {
21 mp_free2(mp, base_len + size + 1, ret);
22 return -1;
23 }
24 if (base)
mp_free2(mp, strlen(base), base);
26 return final_len;
27}
#define mp_free2(p, sz, a)
#define mp_malloc2(p, sz)