blob: e57c32021481d862ee79bca4b274e074827786f0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"
int
libsimple_asprintf(char **strp, const char *fmt, ...)
{
va_list ap;
int r;
va_start(ap, fmt);
r = libsimple_vasprintf(strp, fmt, ap);
va_end(ap);
return r;
}
#ifdef TEST
#include <assert.h>
int
main(void)
{
char *s = "";
char *old = s;
assert(libsimple_asprintf(&s, "%i %X", 99999, 255) == sizeof("99999 FF") - 1);
assert(s && s != old);
assert(!strcmp(s, "99999 FF"));
free(s);
return 0;
}
#endif
|