Ejemplo n.º 1
0
void CMemMgr::mem_free( void *p, bool bAutoHeap )
{
	if ( bAutoHeap )
	{
		// find the current heap
		m_current_freed_heap = FindHeap( p );
		assert( m_current_freed_heap >=0 && m_current_freed_heap < m_num_heaps );
		
		PushHeap(); // keep current heap
		UseHeap( m_current_freed_heap ); // switch to the owner
		mp_heaps[ m_current_heap ].mem_free( p );
		PopHeap();	// restore current heap
	}
	else
	{
		mp_heaps[ m_current_heap ].mem_free( p );
	}
}
Ejemplo n.º 2
0
int main()
{
	heap pq;
	InitHeap(&pq, comp);
	
	PushHeap(&pq, 3343, 1, 0);
	PushHeap(&pq, 13, 1, 0);
	PushHeap(&pq, 241, 1, 0);
	PushHeap(&pq, 54, 1, 0);
	PushHeap(&pq, 2324, 1, 0);
	PushHeap(&pq, 3, 1, 0);
	
	while(!EmptyHeap(&pq))
	{
		printf("%d\n", FrontHeapValue(&pq));
		PopHeap(&pq);
	}
	ClearHeap(&pq);
	return 0;
}