/* deallocate heap-allocated types */ void TypeCleanupNode(Picoc *pc, struct ValueType *Typ){ struct ValueType *SubType; struct ValueType *NextSubType; /* clean up and free all the sub-nodes */ for (SubType = Typ->DerivedTypeList; SubType; SubType = NextSubType){ NextSubType = SubType->Next; TypeCleanupNode(pc, SubType); if (SubType->OnHeap){ /* if it's a struct or union deallocate all the member values */ if (SubType->Members != NULL){ VariableTableCleanup(pc, SubType->Members); HeapFreeMem(pc, SubType->Members); } /* free this node */ HeapFreeMem(pc, SubType); } } }
void TypeCleanup() { TypeCleanupNode(&UberType); }
void TypeCleanup(Picoc *pc){TypeCleanupNode(pc, &pc->UberType);}