This source file includes following definitions.
- my_xasprintf
- test_vsnprintf
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include "unistdio.h"
22
23 #include <errno.h>
24 #include <stdarg.h>
25 #include <stddef.h>
26 #include <stdint.h>
27 #include <stdlib.h>
28 #include <string.h>
29
30 #include "unistr.h"
31 #include "xalloc.h"
32 #include "macros.h"
33
34 #include "test-u8-printf1.h"
35
36 static uint8_t *
37 my_xasprintf (const char *format, ...)
38 {
39 va_list args;
40 uint8_t buf[1000];
41 int retval;
42 size_t length;
43 uint8_t *result;
44
45 va_start (args, format);
46 retval = u8_vsnprintf (buf, sizeof (buf), format, args);
47 va_end (args);
48 if (retval < 0 || retval >= (int) sizeof (buf))
49 return NULL;
50 length = u8_strlen (buf);
51 result = XNMALLOC (length + 1, uint8_t);
52 u8_cpy (result, buf, length + 1);
53 return result;
54 }
55
56 static void
57 test_vsnprintf ()
58 {
59 test_xfunction (my_xasprintf);
60 }
61
62 int
63 main (int argc, char *argv[])
64 {
65 test_vsnprintf ();
66
67 return 0;
68 }