Skip to content

Commit

Permalink
Dynamically compute quine buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
ammrat13 committed Jan 14, 2024
1 parent 3ea44e4 commit 409913f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tccpp_rott-pre.inc
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ static char rott_hex_char(char n) {

static const char *rott_quine_gen(void) {
// Have a buffer in which we compute the quine the first time we're called
static char quine_buf[1048576];
static char rott_quine_buf[6*sizeof(rott_quine_data) + 36 + 3];
static int first_call = 1;

if (first_call) {
// This holds where we will write to next in the buffer
char *buf_ptr = quine_buf;
char *buf_ptr = rott_quine_buf;

// Write the initial header
buf_ptr += sprintf(buf_ptr, ";\n\nstatic char rott_quine_data[] = {");
Expand All @@ -54,7 +54,7 @@ static const char *rott_quine_gen(void) {
}

first_call = 0;
return quine_buf;
return rott_quine_buf;
}

// List of patterns to match on, along with the number of patterns we have. Note
Expand Down

0 comments on commit 409913f

Please sign in to comment.