2010-03-08 06:27:02 +01:00
|
|
|
#include "../Headers/cStandardMemoryProvider.h"
|
2010-03-09 05:40:27 +01:00
|
|
|
#include "../Headers/cMemoryTracker.h"
|
2010-03-08 06:27:02 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <limits>
|
|
|
|
|
2010-03-09 05:40:27 +01:00
|
|
|
#ifdef max
|
|
|
|
#undef max
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef min
|
|
|
|
#undef min
|
|
|
|
#endif
|
|
|
|
|
2010-03-08 06:27:02 +01:00
|
|
|
namespace cAudio
|
|
|
|
{
|
|
|
|
void* cStandardMemoryProvider::Allocate(size_t size, const char* filename, int line, const char* function)
|
|
|
|
{
|
2010-03-09 05:40:27 +01:00
|
|
|
void* ptr = malloc(size);
|
|
|
|
#ifdef CAUDIO_USE_MEMORYTRACKER
|
|
|
|
cMemoryTracker::Instance()->AddAllocation(ptr, size, filename, line, function);
|
|
|
|
#endif
|
|
|
|
return ptr;
|
2010-03-08 06:27:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cStandardMemoryProvider::Free(void* pointer)
|
|
|
|
{
|
|
|
|
if(pointer)
|
|
|
|
{
|
2010-03-09 05:40:27 +01:00
|
|
|
#ifdef CAUDIO_USE_MEMORYTRACKER
|
|
|
|
cMemoryTracker::Instance()->RemoveAllocation(pointer);
|
|
|
|
#endif
|
2010-03-08 06:27:02 +01:00
|
|
|
free(pointer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t cStandardMemoryProvider::getMaxAllocationSize()
|
|
|
|
{
|
|
|
|
return std::numeric_limits<size_t>::max();
|
|
|
|
}
|
|
|
|
};
|