added ActiveMemoryBlockManager::GetOrCreate

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-09-19 20:21:37 +08:00
parent cf1e0340f4
commit 56d98d65e2
2 changed files with 15 additions and 0 deletions

View File

@ -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();

View File

@ -181,6 +181,20 @@ namespace hgl
return(true);
}
bool ActiveMemoryBlockManager::GetOrCreate(int *da,const int count)
{
if(!da||count<=0)return(false);
if(GetIdleCount()<count)
CreateIdle(nullptr,count-GetIdleCount());
if(!Get(da,count))
return(false);
ReallocDataBlock();
return(true);
}
int ActiveMemoryBlockManager::Release(int *id,const int count)
{
return aim.Release(id,count);