History

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 :-/

Michael Matz committed 9 years ago

Commit 4beb4691 parent 42e2a671 file · +6 −5Browse files

Unified · Split

tccpp.c+6−5
@@ -43,6 +43,7 @@ ST_DATA TokenSym **table_ident; · 42 unmodified lines
4343 static TokenSym *hash_ident[TOK_HASH_SIZE];
4444 static char token_buf[STRING_MAX_SIZE + 1];
4545 static CString cstr_buf;
46+static CString macro_equal_buf;
4647 static TokenString tokstr_buf;
4748 static unsigned char isidnum_table[256 - CH_EOF];
4849 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
12831284 {
12841285 CValue cv;
12851286 int t;
1286− static CString localbuf;
12871287
12881288 if (!a || !b)
12891289 return 1;
12901290
12911291 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(&macro_equal_buf);
12941294 TOK_GET(&t, &a, &cv);
1295− cstr_cat(&localbuf, get_tok_str(t, &cv), 0);
1295+ cstr_cat(&macro_equal_buf, get_tok_str(t, &cv), 0);
12961296 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)))
12981298 return 0;
12991299 }
13001300 return !(*a || *b);
@@ -3568,6 +3568,7 @@ ST_FUNC void tccpp_delete(TCCState *s) · 2267 unmodified lines
35683568 /* free static buffers */
35693569 cstr_free(&tokcstr);
35703570 cstr_free(&cstr_buf);
3571+ cstr_free(&macro_equal_buf);
35713572 tok_str_free_str(tokstr_buf.str);
35723573
35733574 /* free allocators */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t