From 595cdebfe7b1bbb1a1b05b75ae5e4d4703b0e9a2 Mon Sep 17 00:00:00 2001 From: silvio3105 <104866334+silvio3105@users.noreply.github.com> Date: Sun, 31 May 2026 01:25:07 +0200 Subject: [PATCH 1/2] Added support for PRINTF_NO_STACK_BUFFER #226. --- src/printf/printf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/printf/printf.c b/src/printf/printf.c index 824e469..d21f38f 100644 --- a/src/printf/printf.c +++ b/src/printf/printf.c @@ -614,7 +614,11 @@ static void print_integer_finalization(output_gadget_t* output, char* buf, print /* An internal itoa-like function */ static void print_integer(output_gadget_t* output, printf_unsigned_value_t value, bool negative, numeric_base_t base, printf_size_t precision, printf_size_t width, printf_flags_t flags) { + #ifdef PRINTF_NO_STACK_BUFFER + static char buf[PRINTF_INTEGER_BUFFER_SIZE] = { 0 }; + #else char buf[PRINTF_INTEGER_BUFFER_SIZE]; + #endif // PRINTF_NO_STACK_BUFFER printf_size_t len = 0U; if (!value) { @@ -1156,7 +1160,11 @@ static void print_exponential_number(output_gadget_t* output, floating_point_t n static void print_floating_point(output_gadget_t* output, floating_point_t value, printf_size_t precision, printf_size_t width, printf_flags_t flags, bool prefer_exponential) { + #ifdef PRINTF_NO_STACK_BUFFER + static char buf[PRINTF_DECIMAL_BUFFER_SIZE] = { 0 }; + #else char buf[PRINTF_DECIMAL_BUFFER_SIZE]; + #endif // PRINTF_NO_STACK_BUFFER printf_size_t len = 0U; /* test for special values */ From bcf8ca6ece2bf18bb379e24670bf3bf0d0c0b38f Mon Sep 17 00:00:00 2001 From: silvio3105 <104866334+silvio3105@users.noreply.github.com> Date: Sun, 31 May 2026 01:44:26 +0200 Subject: [PATCH 2/2] Updated README.md #226. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 70d4bfc..8984a7c 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ Options used both in CMake and in the library source code via a preprocessor def | SUPPORT_WRITEBACK_SPECIFIER | YES | Support the length write-back specifier (%n) | | SUPPORT_LONG_LONG | YES | Support long long integral types (allows for the ll length modifier and affects %p) | | USE_DOUBLE_INTERNALLY | YES | Use the `double` for internal floating-point calculations (rather than using the single-precision `float` type | +| NO_STACK_BUFFER | NO | Define buffers as static | In the source files themselves, these options become preprocessor definitions with a `PRINTF_` prefix; the boolean ones have value `1` OR `0` for YES or NO respectively; and the aliasing option translates into one of three definitions: `ALIAS_STANDARD_FUNCTION_NAMES_NONE`, `ALIAS_STANDARD_FUNCTION_NAMES_SOFT` or `ALIAS_STANDARD_FUNCTION_NAMES_HARD`.