library/src/garbage_collection/BP_MemoryGarbageCollector.cc
// returns the heap chunk index, searched by pointer
returns the heap chunk index, searched by pointer
returns the heap chunk index searched by pointer
P_BP_GARBAGE_COLLECTOR_ALLOC_CHUNK BP_GarbageCollectorLookupPtrPosition(P_BP_GARBAGE_COLLECTOR_DATA gc, void *ptr)
{
	if(!gc)
		return NULL;
	if(!gc->chunks)
		return NULL;
	size_t i = 0;
	P_BP_GARBAGE_COLLECTOR_ALLOC_CHUNK chunks = gc->chunks->first;
	for(chunks = chunks->first; chunks; chunks = chunks->next)
	{
		if(chunks->chunk_ptr == ptr)
			return chunks;
	}
	return NULL;
}
P_BP_GARBAGE_COLLECTOR_ALLOC_CHUNK BP_GarbageCollectorLookupPtrPosition ( P_BP_GARBAGE_COLLECTOR_DATA gc , void * ptr ) { if ( ! gc ) return NULL ; if ( ! gc -> chunks ) return NULL ; size_t i = 0 ; P_BP_GARBAGE_COLLECTOR_ALLOC_CHUNK chunks = gc -> chunks -> first ; for ( chunks = chunks -> first ; chunks ; chunks = chunks -> next ) { if ( chunks -> chunk_ptr == ptr ) return chunks ; } return NULL ; }
returns the heap chunk index, searched by pointer
returns the heap chunk index searched by pointer
// linear search chunk stack looking for pointer // save first pointer // run linear search // return the pointer in the case of a match // return indicating failure