diff --git a/inc/hgl/type/MemoryAllocator.h b/inc/hgl/type/MemoryAllocator.h index 17fae3f..035b069 100644 --- a/inc/hgl/type/MemoryAllocator.h +++ b/inc/hgl/type/MemoryAllocator.h @@ -1,4 +1,4 @@ -#ifndef HGL_MEMORY_ALLOCATOR_INCLUDE +#ifndef HGL_MEMORY_ALLOCATOR_INCLUDE #define HGL_MEMORY_ALLOCATOR_INCLUDE #include @@ -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 diff --git a/inc/hgl/type/MemoryBlock.h b/inc/hgl/type/MemoryBlock.h index eaf045a..f4d5066 100644 --- a/inc/hgl/type/MemoryBlock.h +++ b/inc/hgl/type/MemoryBlock.h @@ -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); diff --git a/src/Other/MemoryAllocator.cpp b/src/Other/MemoryAllocator.cpp index e879a15..90f112b 100644 --- a/src/Other/MemoryAllocator.cpp +++ b/src/Other/MemoryAllocator.cpp @@ -1,4 +1,4 @@ -#include +#include namespace hgl { diff --git a/src/Other/MemoryBlock.cpp b/src/Other/MemoryBlock.cpp index 35491f8..dc9b416 100644 --- a/src/Other/MemoryBlock.cpp +++ b/src/Other/MemoryBlock.cpp @@ -1,4 +1,4 @@ -#include +#include #include 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);