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 :-/
Unified · Split
| @@ -43,6 +43,7 @@ ST_DATA TokenSym **table_ident; · 42 unmodified lines | ||
| 43 | 43 | static TokenSym *hash_ident[TOK_HASH_SIZE]; |
| 44 | 44 | static char token_buf[STRING_MAX_SIZE + 1]; |
| 45 | 45 | static CString cstr_buf; |
| 46 | +static CString macro_equal_buf; | |
| 46 | 47 | static TokenString tokstr_buf; |
| 47 | 48 | static unsigned char isidnum_table[256 - CH_EOF]; |
| 48 | 49 | static int pp_debug_tok, pp_debug_symv; |
| @@ -1283,18 +1284,17 @@ static int macro_is_equal(const int *a, const int *b) · 1234 unmodified lines | ||
| 1283 | 1284 | { |
| 1284 | 1285 | CValue cv; |
| 1285 | 1286 | int t; |
| 1286 | − static CString localbuf; | |
| 1287 | 1287 | |
| 1288 | 1288 | if (!a || !b) |
| 1289 | 1289 | return 1; |
| 1290 | 1290 | |
| 1291 | 1291 | while (*a && *b) { |
| 1292 | − /* first time preallocate static localbuf, next time only reset position to start */ | |
| 1293 | − cstr_reset(&localbuf); | |
| 1292 | + /* first time preallocate macro_equal_buf, next time only reset position to start */ | |
| 1293 | + cstr_reset(¯o_equal_buf); | |
| 1294 | 1294 | TOK_GET(&t, &a, &cv); |
| 1295 | − cstr_cat(&localbuf, get_tok_str(t, &cv), 0); | |
| 1295 | + cstr_cat(¯o_equal_buf, get_tok_str(t, &cv), 0); | |
| 1296 | 1296 | TOK_GET(&t, &b, &cv); |
| 1297 | − if (strcmp(localbuf.data, get_tok_str(t, &cv))) | |
| 1297 | + if (strcmp(macro_equal_buf.data, get_tok_str(t, &cv))) | |
| 1298 | 1298 | return 0; |
| 1299 | 1299 | } |
| 1300 | 1300 | return !(*a || *b); |
| @@ -3568,6 +3568,7 @@ ST_FUNC void tccpp_delete(TCCState *s) · 2267 unmodified lines | ||
| 3568 | 3568 | /* free static buffers */ |
| 3569 | 3569 | cstr_free(&tokcstr); |
| 3570 | 3570 | cstr_free(&cstr_buf); |
| 3571 | + cstr_free(¯o_equal_buf); | |
| 3571 | 3572 | tok_str_free_str(tokstr_buf.str); |
| 3572 | 3573 | |
| 3573 | 3574 | /* free allocators */ |