ucx/printf.c

changeset 101
7b3a3130be44
parent 49
2f71f4ee247a
equal deleted inserted replaced
100:d2bd73d28ff1 101:7b3a3130be44
32 #include <string.h> 32 #include <string.h>
33 33
34 #ifndef CX_PRINTF_SBO_SIZE 34 #ifndef CX_PRINTF_SBO_SIZE
35 #define CX_PRINTF_SBO_SIZE 512 35 #define CX_PRINTF_SBO_SIZE 512
36 #endif 36 #endif
37 unsigned const cx_printf_sbo_size = CX_PRINTF_SBO_SIZE; 37 const unsigned cx_printf_sbo_size = CX_PRINTF_SBO_SIZE;
38 38
39 int cx_fprintf( 39 int cx_fprintf(
40 void *stream, 40 void *stream,
41 cx_write_func wfc, 41 cx_write_func wfc,
42 const char *fmt, 42 const char *fmt,
67 va_end(ap2); 67 va_end(ap2);
68 return (int) wfc(buf, 1, ret, stream); 68 return (int) wfc(buf, 1, ret, stream);
69 } else { 69 } else {
70 int len = ret + 1; 70 int len = ret + 1;
71 char *newbuf = malloc(len); 71 char *newbuf = malloc(len);
72 if (!newbuf) { 72 if (!newbuf) { // LCOV_EXCL_START
73 va_end(ap2); 73 va_end(ap2);
74 return -1; 74 return -1;
75 } 75 } // LCOV_EXCL_STOP
76 76
77 ret = vsnprintf(newbuf, len, fmt, ap2); 77 ret = vsnprintf(newbuf, len, fmt, ap2);
78 va_end(ap2); 78 va_end(ap2);
79 if (ret > 0) { 79 if (ret > 0) {
80 ret = (int) wfc(newbuf, 1, ret, stream); 80 ret = (int) wfc(newbuf, 1, ret, stream);

mercurial