From 56d98d65e239b36544e41515c6277f88f9efdbcb Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Tue, 19 Sep 2023 20:21:37 +0800 Subject: [PATCH] added ActiveMemoryBlockManager::GetOrCreate --- inc/hgl/type/ActiveMemoryBlockManager.h | 1 + src/Type/ActiveMemoryBlockManager.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/inc/hgl/type/ActiveMemoryBlockManager.h b/inc/hgl/type/ActiveMemoryBlockManager.h index febd313..0bce2a1 100644 --- a/inc/hgl/type/ActiveMemoryBlockManager.h +++ b/inc/hgl/type/ActiveMemoryBlockManager.h @@ -52,6 +52,7 @@ namespace hgl int CreateIdle(int *da,const int count=1); bool Get(int *da,const int count=1); + bool GetOrCreate(int *da,const int count=1); int Release(int *id,const int count=1); int ReleaseAllActive(); diff --git a/src/Type/ActiveMemoryBlockManager.cpp b/src/Type/ActiveMemoryBlockManager.cpp index e73c77b..ab2393f 100644 --- a/src/Type/ActiveMemoryBlockManager.cpp +++ b/src/Type/ActiveMemoryBlockManager.cpp @@ -181,6 +181,20 @@ namespace hgl return(true); } + bool ActiveMemoryBlockManager::GetOrCreate(int *da,const int count) + { + if(!da||count<=0)return(false); + + if(GetIdleCount()