Skip to content

Commit

Permalink
Don't call StringTable's destructor from the glue layer
Browse files Browse the repository at this point in the history
  • Loading branch information
yebblies committed Jan 20, 2015
1 parent 7eb34f4 commit a3350a8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/e2ir.c
Expand Up @@ -854,9 +854,13 @@ StringTable *stringTab;
void clearStringTab()
{
//printf("clearStringTab()\n");
delete stringTab;
stringTab = new StringTable;
stringTab->_init(1000); // 1000 is arbitrary guess
if (stringTab)
stringTab->reset(1000); // 1000 is arbitrary guess
else
{
stringTab = new StringTable();
stringTab->_init(1000);
}
}

elem *toElem(Expression *e, IRState *irs)
Expand Down
12 changes: 12 additions & 0 deletions src/root/stringtable.c
Expand Up @@ -132,6 +132,18 @@ void StringTable::_init(size_t size)
count = 0;
}

void StringTable::reset(size_t size)
{
for (size_t i = 0; i < npools; ++i)
mem.free(pools[i]);

mem.free(table);
mem.free(pools);
table = NULL;
pools = NULL;
_init(size);
}

StringTable::~StringTable()
{
for (size_t i = 0; i < npools; ++i)
Expand Down
1 change: 1 addition & 0 deletions src/root/stringtable.h
Expand Up @@ -46,6 +46,7 @@ struct StringTable

public:
void _init(size_t size = 0);
void reset(size_t size = 0);
~StringTable();

StringValue *lookup(const char *s, size_t len);
Expand Down

0 comments on commit a3350a8

Please sign in to comment.