From 4beb469c91ef831826047955abc1679ab96dcd98 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Tue, 20 Dec 2016 05:38:44 +0100 Subject: [PATCH] Fix pseudo leak Once-allocated buffers (here a string) that aren't explicitely freed at program end but rather freed at _exit about 1 nanosecond later are regarded a leak with MEM_DEBUG, so explicitely free it. Blaeh :-/ --- tccpp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tccpp.c b/tccpp.c index c069a24..8cc9510 100644 --- a/tccpp.c +++ b/tccpp.c @@ -43,6 +43,7 @@ ST_DATA TokenSym **table_ident; static TokenSym *hash_ident[TOK_HASH_SIZE]; static char token_buf[STRING_MAX_SIZE + 1]; static CString cstr_buf; +static CString macro_equal_buf; static TokenString tokstr_buf; static unsigned char isidnum_table[256 - CH_EOF]; static int pp_debug_tok, pp_debug_symv; @@ -1283,18 +1284,17 @@ static int macro_is_equal(const int *a, const int *b) { CValue cv; int t; - static CString localbuf; if (!a || !b) return 1; while (*a && *b) { - /* first time preallocate static localbuf, next time only reset position to start */ - cstr_reset(&localbuf); + /* first time preallocate macro_equal_buf, next time only reset position to start */ + cstr_reset(¯o_equal_buf); TOK_GET(&t, &a, &cv); - cstr_cat(&localbuf, get_tok_str(t, &cv), 0); + cstr_cat(¯o_equal_buf, get_tok_str(t, &cv), 0); TOK_GET(&t, &b, &cv); - if (strcmp(localbuf.data, get_tok_str(t, &cv))) + if (strcmp(macro_equal_buf.data, get_tok_str(t, &cv))) return 0; } return !(*a || *b); @@ -3568,6 +3568,7 @@ ST_FUNC void tccpp_delete(TCCState *s) /* free static buffers */ cstr_free(&tokcstr); cstr_free(&cstr_buf); + cstr_free(¯o_equal_buf); tok_str_free_str(tokstr_buf.str); /* free allocators */