diff --git a/asm/preproc.c b/asm/preproc.c index 95ca56fc..26cf3002 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -1192,6 +1192,19 @@ static void delete_Blocks(void) memset(&blocks, 0, sizeof(blocks)); } +static FILE * logfile = NULL; +static unsigned long logamount = 0; +static unsigned long logtotal = 0; +static unsigned long logmodulo = 0; + +static void openlogfile(void); +static void openlogfile(void) { + if (logfile) return; + logfile = fopen("nasmtoka.log", "wb"); + if (!logfile) nasm_panic(0, "unable to open log file"); + return; +} + /* * this function creates a new Token and passes a pointer to it * back to the caller. It sets the type and text elements, and @@ -1202,6 +1215,13 @@ static Token *new_Token(Token * next, enum pp_token_type type, { Token *t; int i; + openlogfile(); + logamount++; + logtotal++; + if ((logmodulo++ & 8191) == 0) { + fprintf(logfile, "[%12lu] (%12lu) allocate\n", logamount, logtotal); + fflush(logfile); + } if (!freeTokens) { freeTokens = (Token *) new_Block(TOKEN_BLOCKSIZE * sizeof(Token)); @@ -1229,6 +1249,12 @@ static Token *new_Token(Token * next, enum pp_token_type type, static Token *delete_Token(Token * t) { Token *next = t->next; + openlogfile(); + logamount--; + if ((logmodulo++ & 8191) == 0) { + fprintf(logfile, "[%12lu] (%12lu) delete\n", logamount, logtotal); + fflush(logfile); + } nasm_free(t->text); t->next = freeTokens; freeTokens = t;