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:
parent
3448e70551
commit
028c98d665
1
picoc.c
1
picoc.c
|
@ -16,6 +16,7 @@ void Initialise()
|
|||
/* free memory */
|
||||
void Cleanup()
|
||||
{
|
||||
VariableCleanup();
|
||||
TableStrFree();
|
||||
}
|
||||
|
||||
|
|
1
picoc.h
1
picoc.h
|
@ -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);
|
||||
|
|
22
variable.c
22
variable.c
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue