2016-01-12 13:08:26 -05:00
|
|
|
#include "STDInclude.hpp"
|
|
|
|
|
|
|
|
namespace Utils
|
|
|
|
{
|
|
|
|
void* Memory::Allocate(size_t length)
|
|
|
|
{
|
|
|
|
void* data = new char[length];
|
|
|
|
|
2016-06-08 11:28:58 -04:00
|
|
|
assert(data != nullptr);
|
|
|
|
|
2016-01-12 13:08:26 -05:00
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
ZeroMemory(data, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* Memory::DuplicateString(std::string string)
|
|
|
|
{
|
|
|
|
char* newString = Memory::AllocateArray<char>(string.size() + 1);
|
|
|
|
memcpy(newString, string.data(), string.size());
|
|
|
|
return newString;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Memory::Free(void* data)
|
|
|
|
{
|
2016-06-08 11:28:58 -04:00
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
delete[] data;
|
|
|
|
}
|
2016-01-12 13:08:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void Memory::Free(const void* data)
|
|
|
|
{
|
2016-01-24 06:19:34 -05:00
|
|
|
Memory::Free(const_cast<void*>(data));
|
2016-01-12 13:08:26 -05:00
|
|
|
}
|
|
|
|
}
|