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); |
83 } |
83 } |
84 return ret; |
84 return ret; |
85 } |
85 } |
86 |
86 |
87 cxmutstr cx_asprintf_a( |
87 cxmutstr cx_asprintf_a( |
88 CxAllocator const *allocator, |
88 const CxAllocator *allocator, |
89 char const *fmt, |
89 const char *fmt, |
90 ... |
90 ... |
91 ) { |
91 ) { |
92 va_list ap; |
92 va_list ap; |
93 va_start(ap, fmt); |
93 va_start(ap, fmt); |
94 cxmutstr ret = cx_vasprintf_a(allocator, fmt, ap); |
94 cxmutstr ret = cx_vasprintf_a(allocator, fmt, ap); |
95 va_end(ap); |
95 va_end(ap); |
96 return ret; |
96 return ret; |
97 } |
97 } |
98 |
98 |
99 cxmutstr cx_vasprintf_a( |
99 cxmutstr cx_vasprintf_a( |
100 CxAllocator const *a, |
100 const CxAllocator *a, |
101 char const *fmt, |
101 const char *fmt, |
102 va_list ap |
102 va_list ap |
103 ) { |
103 ) { |
104 cxmutstr s; |
104 cxmutstr s; |
105 s.ptr = NULL; |
105 s.ptr = NULL; |
106 s.length = 0; |
106 s.length = 0; |