added Free() function at MemoryBlock/MemoryAllocator class.

This commit is contained in:
hyzboy 2021-03-20 12:39:02 +08:00
parent aca6aa4ee2
commit 6f63956b9d
4 changed files with 11 additions and 5 deletions

View File

@ -1,4 +1,4 @@
#ifndef HGL_MEMORY_ALLOCATOR_INCLUDE
#ifndef HGL_MEMORY_ALLOCATOR_INCLUDE
#define HGL_MEMORY_ALLOCATOR_INCLUDE
#include<hgl/type/DataType.h>
@ -66,7 +66,7 @@ namespace hgl
virtual ~MemoryAllocator();
virtual bool Alloc(const uint64 size);
virtual void Free();
virtual void Free() override;
};//class MemoryAllocator:public AbstractMemoryAllocator
}//namespace hgl
#endif//HGL_MEMORY_ALLOCATOR_INCLUDE

View File

@ -29,6 +29,7 @@ namespace hgl
virtual void * Get (const uint64 offset) {return memory_allocator->Get(offset);}
virtual void Clear ();
virtual void Free ();
virtual bool Alloc (const uint64 size,const uint64 uint_size=0);
virtual bool Write (const uint64 target,const void *source,const uint64 size);
virtual bool Write (const uint64 target,MemoryBlock *source,const uint64 offset,const uint64 size);

View File

@ -1,4 +1,4 @@
#include<hgl/type/MemoryAllocator.h>
#include<hgl/type/MemoryAllocator.h>
namespace hgl
{

View File

@ -1,4 +1,4 @@
#include<hgl/type/MemoryBlock.h>
#include<hgl/type/MemoryBlock.h>
#include<string.h>
namespace hgl
{
@ -13,7 +13,7 @@ namespace hgl
MemoryBlock::~MemoryBlock()
{
hgl_free(temp_block);
SAFE_CLEAR(memory_allocator); //会同步释放内存
SAFE_CLEAR(memory_allocator); //会同步释放内存
}
void MemoryBlock::Clear()
@ -21,6 +21,11 @@ namespace hgl
memory_allocator->Clear();
}
void MemoryBlock::Free()
{
memory_allocator->Free();
}
bool MemoryBlock::Alloc(const uint64 size,const uint64 uint_size)
{
memory_allocator->SetAllocUnitSize(uint_size);