diff -r 98c90759f69e -r 5700ba9154ab src/printf.c --- a/src/printf.c Wed Feb 01 17:14:17 2023 +0100 +++ b/src/printf.c Wed Feb 01 18:06:50 2023 +0100 @@ -31,9 +31,16 @@ #include #include -#define CX_PRINTF_BUFSIZE 256 +#ifndef CX_PRINTF_SBO_SIZE +#define CX_PRINTF_SBO_SIZE 512 +#endif -int cx_fprintf(void *stream, cx_write_func wfc, char const *fmt, ...) { +int cx_fprintf( + void *stream, + cx_write_func wfc, + char const *fmt, + ... +) { int ret; va_list ap; va_start(ap, fmt); @@ -43,13 +50,13 @@ } int cx_vfprintf(void *stream, cx_write_func wfc, char const *fmt, va_list ap) { - char buf[CX_PRINTF_BUFSIZE]; + char buf[CX_PRINTF_SBO_SIZE]; va_list ap2; va_copy(ap2, ap); - int ret = vsnprintf(buf, CX_PRINTF_BUFSIZE, fmt, ap); + int ret = vsnprintf(buf, CX_PRINTF_SBO_SIZE, fmt, ap); if (ret < 0) { return ret; - } else if (ret < CX_PRINTF_BUFSIZE) { + } else if (ret < CX_PRINTF_SBO_SIZE) { return (int) wfc(buf, 1, ret, stream); } else { int len = ret + 1; @@ -80,11 +87,11 @@ cxmutstr s; s.ptr = NULL; s.length = 0; - char buf[CX_PRINTF_BUFSIZE]; + char buf[CX_PRINTF_SBO_SIZE]; va_list ap2; va_copy(ap2, ap); - int ret = vsnprintf(buf, CX_PRINTF_BUFSIZE, fmt, ap); - if (ret > 0 && ret < CX_PRINTF_BUFSIZE) { + int ret = vsnprintf(buf, CX_PRINTF_SBO_SIZE, fmt, ap); + if (ret > 0 && ret < CX_PRINTF_SBO_SIZE) { s.ptr = cxMalloc(a, ret + 1); if (s.ptr) { s.length = (size_t) ret;