/*
This block of code is expected to override the memory allocater in the DPL library
*/
#include <mungal4.hpp>
#pragma hdrstop

#if !defined(L4VIDEO_HPP)
#	include <l4video.hpp>
#endif

extern "C"
{
	void
		*dpl_malloc ( int n_bytes ),
		*dpl_calloc ( size_t n, size_t n_bytes ),
		dpl_free ( void *ptr ),
		dpl_free_all ( void );
};

void *dpl_malloc ( int n_bytes )
{
	Check_Pointer(DPLRenderer::DPLHeap);
	return DPLRenderer::DPLHeap->Allocate(n_bytes);
}

void *dpl_calloc ( size_t n, size_t n_bytes )
{
	Check_Pointer(DPLRenderer::DPLHeap);
	void *p	=	DPLRenderer::DPLHeap->Allocate(n * n_bytes);
	memset ( p, 0x0, n_bytes*n );
	return p;
}

void dpl_free ( void *ptr )
{
	Check_Pointer(DPLRenderer::DPLHeap);
	DPLRenderer::DPLHeap->Release(ptr);
}

void dpl_free_all ( void )
{
	Check_Pointer(DPLRenderer::DPLHeap);
	DPLRenderer::DPLHeap->ReleaseAll();
}

