From f19ab30886a2cbb811d77631d799ae2a7c93208f Mon Sep 17 00:00:00 2001 From: bulk88 Date: Sat, 5 Oct 2024 15:40:43 -0400 Subject: [PATCH] * refactor generate_uudmap.c part 4 -this commit is probably for a future change requiring a generated .h involving sv_inline.h -buffer format_char_block data in stack memory until about a full line is reached, avoids expensive lock and unlocking inside all libcs (os threads) --- generate_uudmap.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/generate_uudmap.c b/generate_uudmap.c index 844870da4973..f16db1dee2be 100644 --- a/generate_uudmap.c +++ b/generate_uudmap.c @@ -124,9 +124,13 @@ format_mg_data(FILE *out, const void *thing, unsigned int count) { static void format_char_block(FILE *out, const void *thing, unsigned int count) { + char buf [(sizeof("-255,\n ")-1) * 256]; /* 2048, oversized vs ~900 */ + char * start = buf; + char * p = start; + char * p2; const char *block = (const char *)thing; - fputs(" ", out); + xstrputs(" "); while (count--) { const char * fmt; char c = *block; @@ -139,9 +143,10 @@ format_char_block(FILE *out, const void *thing, unsigned int count) { } else fmt = "%d"; - fprintf(out, fmt, c); + p += sprintf(p, fmt, c); } - fputc('\n', out); + xstrputc('\n'); + fwrite(start, sizeof(char), p-start, out); } static void