| 4178 | } |
| 4179 | |
| 4180 | static int vfprintf_unlocked(FILE *stream, const char *format, va_list ap) |
| 4181 | { |
| 4182 | va_list aq; |
| 4183 | va_copy(aq, ap); |
| 4184 | int result = vsnprintf(NULL, SIZE_MAX, format, ap); |
| 4185 | if (result >= 0) |
| 4186 | { |
| 4187 | ssize_t size = result+1; |
| 4188 | PRINTF_BUF_ALLOC(buf, size); |
| 4189 | if (buf != NULL) |
| 4190 | { |
| 4191 | result = vsnprintf(buf, result+1, format, aq); |
| 4192 | if (result >= 0) |
| 4193 | { |
| 4194 | if (fputs_unlocked(buf, stream)) |
| 4195 | result = -1; |
| 4196 | } |
| 4197 | PRINT_BUF_FREE(buf); |
| 4198 | } |
| 4199 | } |
| 4200 | va_end(aq); |
| 4201 | return result; |
| 4202 | } |
| 4203 | |
| 4204 | static int fprintf(FILE *stream, const char *format, ...) |
| 4205 | { |
no test coverage detected