/*-------------------------------------------------------------------------*/ void clear_struct_type_ref (struct_type_t * pSType) /* Clear all references held by struct typeobject <pSType> */ { unsigned short num; if (pSType->ref != 0) { clear_memory_reference(pSType); if (pSType->member) clear_memory_reference(pSType->member); pSType->ref = 0; clear_struct_name_ref(pSType->name); if (pSType->unique_name) pSType->unique_name->info.ref = 0; if (pSType->base) clear_struct_type_ref(pSType->base); for (num = struct_t_size(pSType); num-- > 0; ) { pSType->member[num].name->info.ref = 0; clear_lpctype_ref(pSType->member[num].type); } } } /* clear_struct_type_ref() */
void mempool_clear_refs (Mempool pPool) /* GC Support: Clear the refs of all memory associated with <pPool> and * its dependees. */ { Memblock pBlock; clear_memory_reference(pPool); for (pBlock = pPool->pBlocks; pBlock; pBlock = pBlock->pNext) clear_memory_reference(pBlock); for (pBlock = pPool->pFree; pBlock; pBlock = pBlock->pNext) clear_memory_reference(pBlock); for (pPool = pPool->pSubPools; pPool != NULL; pPool = pPool->pNextSub) mempool_clear_refs(pPool); } /* mempool_clear_refs() */
void mb_clear_refs (void) /* GC Support: Clear the refs of all memory associated with the * memory buffers. */ { int i; for (i = 0; i < mbMax; i++) { if (membuffers[i].mem != NULL) clear_memory_reference(membuffers[i].mem); } } /* mb_clear_refs() */
/*-------------------------------------------------------------------------*/ void clear_lpctype_ref (lpctype_t *t) /* Clear all references by <t>. */ { if (!t) return; if (!t->t_static) { /* Just in case the allocator forgot something... */ clear_memory_reference(t); t->ref = 0; } /* Not reference counted pointers become NULL, so they don't * become dangling pointers after GC collected their blocks. */ t->array_of = NULL; t->unions_of = NULL; switch(t->t_class) { case TCLASS_PRIMARY: break; /* Can't happen. See above. */ case TCLASS_STRUCT: if (t->t_struct) clear_struct_type_ref(t->t_struct); break; case TCLASS_ARRAY: clear_lpctype_ref(t->t_array.element); break; case TCLASS_UNION: clear_lpctype_ref(t->t_union.head); clear_lpctype_ref(t->t_union.member); t->t_union.next = NULL; break; } } /* clear_lpctype_ref() */
/*-------------------------------------------------------------------------*/ void clear_struct_ref (struct_t * pStruct) /* Clear all references held by struct <pStruct> */ { if (pStruct->ref != 0) { clear_memory_reference(pStruct); pStruct->ref = 0; clear_struct_type_ref(pStruct->type); if (struct_size(pStruct)) { clear_ref_in_vector(pStruct->member, struct_size(pStruct)); } } } /* clear_struct_ref() */
/*-------------------------------------------------------------------------*/ void clear_struct_name_ref (struct_name_t * pSName) /* Clear all references held by struct name object <pSName> */ { if (pSName->ref != 0) { clear_memory_reference(pSName); pSName->ref = 0; pSName->name->info.ref = 0; pSName->prog_name->info.ref = 0; pSName->lpctype = NULL; pSName->current = NULL; } } /* clear_struct_name_ref() */