Now cleaning up more stuff

git-svn-id: http://picoc.googlecode.com/svn/trunk@194 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2009-03-11 10:01:32 +00:00
parent 3448e70551
commit 028c98d665
3 changed files with 24 additions and 0 deletions

View file

@ -16,6 +16,7 @@ void Initialise()
/* free memory */
void Cleanup()
{
VariableCleanup();
TableStrFree();
}

View file

@ -295,6 +295,7 @@ void HeapFree(void *Mem);
/* variable.c */
void VariableInit();
void VariableCleanup();
void *VariableAlloc(struct ParseState *Parser, int Size, int OnHeap);
void VariableStackPop(struct ParseState *Parser, struct Value *Var);
struct Value *VariableAllocValueAndData(struct ParseState *Parser, int DataSize, int IsLValue, struct Value *LValueFrom, int OnHeap);

View file

@ -15,6 +15,28 @@ void VariableInit()
TopStackFrame = NULL;
}
/* deallocate the global table */
void VariableCleanup()
{
struct TableEntry *Entry;
struct TableEntry *NextEntry;
struct Value *Val;
int Count;
for (Count = 0; Count < GlobalTable.Size; Count++)
{
for (Entry = GlobalTable.HashTable[Count]; Entry != NULL; Entry = NextEntry)
{
NextEntry = Entry->Next;
Val = Entry->p.v.Val;
if (Val->ValOnHeap)
HeapFree(Val);
HeapFree(Entry);
}
}
}
/* allocate some memory, either on the heap or the stack and check if we've run out */
void *VariableAlloc(struct ParseState *Parser, int Size, int OnHeap)
{