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