Skip to content

Commit

Permalink
* refactor generate_uudmap.c part 4
Browse files Browse the repository at this point in the history
-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)
  • Loading branch information
bulk88 committed Oct 7, 2024
1 parent 08cde4b commit f19ab30
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions generate_uudmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit f19ab30

Please sign in to comment.