/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/src/sgx/core/memory/cmemory.cpp

*/

#include "sgx/core/core.hpp"
#include "sgx/core/memory/cmemory.h"

void *sgxAllocWrapper(int sz) {
return (void *) new tBYTE[sz];
	return CSGXMemoryAllocator::alloc(sz, CSGXMemoryAllocator::m_DefaultAlignment, __FILE__, __LINE__);
}

void *sgxCallocWrapper(int sz, int isz) {
void *ptr = (void *) new tBYTE[sz*isz];
//	void *ptr = CSGXMemoryAllocator::alloc(sz * isz, CSGXMemoryAllocator::m_DefaultAlignment, __FILE__, __LINE__);
	sgxMemset(ptr, '\0', sz * isz);
	return ptr;
}

void *sgxReallocWrapper(void *pPrevious, int sz) {
	void *pNew = CSGXMemoryAllocator::alloc(sz, CSGXMemoryAllocator::m_DefaultAlignment, __FILE__, __LINE__);

	tMEM_SIZE origSize = CSGXMemoryAllocator::getSize(pPrevious);

	sgxMemcpy(pNew, pPrevious, sgxMin<int>(sz, origSize));
	sgxFreeWrapper(pPrevious);
	return pNew;
}

void  sgxFreeWrapper(void *ptr) {
delete[] (tBYTE*)ptr;
	//CSGXMemoryAllocator::free(ptr);
}

