// DWBS ------------------------------------------------------------------ DWBS
//
// PLATFORM		: PS2 PSP-ADHOC PSP-INFRA PS3
// PRODUCT		: BIT_DEMON
// VISIBILITY	: PUBLIC
//
// DWBS ------------------------------------------------------------------ DWBS

#if defined (BD_PLATFORM_PS2) || defined (BD_PLATFORM_PSP) || defined (BD_PLATFORM_PS3)

#include <stdlib.h>

inline 
void* BD_CALL bdMalloc(bdUWord size)
{
	void *const ptr = ::malloc(size);
	return ptr;
}

inline 
void BD_CALL bdFree(void *p)
{
	::free(p);
}

inline 
void* BD_CALL bdRealloc(void *p,
										bdUWord size)
{
	void *const ptr = ::realloc(p, size);
	return ptr;
}
/*
inline 
void* BD_CALL bdPlatformMemory::alignedMalloc(bdUInt32 size,
											  bdUInt32 align)
{
	void *const ptr = ::memalign(align, size);
	return ptr;
}

inline 
void BD_CALL bdPlatformMemory::alignedFree(void *p)
{
	::free(p);
}

inline 
void* BD_CALL bdPlatformMemory::alignedRealloc(void *p,
											   bdUInt32 size,
											   bdUInt32 align)
{
	void *const ptr = bdPlatformMemory::alignedMalloc(size, align);
	// dodgy if size is greater than the original memory block size
	bdPlatformMemory::memcpy(ptr, p, size);
	bdPlatformMemory::alignedFree(p);
	return ptr;
}
*/
#else

# error BD_PLATFORM_PS2 or BD_PLATFORM_PSP must be defined to use memory functions.

#endif // defined (BD_PLATFORM_PS2)
