From 0786f4c6118f4204c3e4cc312bf6abc7b249b73a Mon Sep 17 00:00:00 2001 From: hyzboy Date: Mon, 26 Aug 2019 21:18:43 +0800 Subject: [PATCH] =?UTF-8?q?ResManage=E6=A8=A1=E6=9D=BFRelease=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=A2=9E=E5=8A=A0=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/type/ResManage.cpp | 19 ++++++++++++------- inc/hgl/type/ResManage.h | 6 +++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/inc/hgl/type/ResManage.cpp b/inc/hgl/type/ResManage.cpp index c95833c..2fcd412 100644 --- a/inc/hgl/type/ResManage.cpp +++ b/inc/hgl/type/ResManage.cpp @@ -122,36 +122,41 @@ namespace hgl } template - void ResManage::ReleaseBySerial(int index,bool zero_clear) + uint ResManage::ReleaseBySerial(int index,bool zero_clear) { if(index==-1) { // ErrorHint(u"所释放的资源不存在"); - return; + return(0); } ResItem *obj=items.GetItem(index); --obj->count; - if(zero_clear&&obj->count==0) + if(obj->count>0) + return obj->count; + + if(zero_clear) { Clear(obj->right); items.DeleteBySerial(index); } + + return 0; } template - void ResManage::Release(const F &flag,bool zero_clear) + uint ResManage::Release(const F &flag,bool zero_clear) { - ReleaseBySerial(items.Find(flag),zero_clear); + return ReleaseBySerial(items.Find(flag),zero_clear); } template - void ResManage::Release(T *td,bool zero_clear) + uint ResManage::Release(T *td,bool zero_clear) { - ReleaseBySerial(items.FindByValue(td),zero_clear); + return ReleaseBySerial(items.FindByValue(td),zero_clear); } }//namespace hgl #endif//HGL_RES_MANAGE_CPP diff --git a/inc/hgl/type/ResManage.h b/inc/hgl/type/ResManage.h index e5d793a..410bc8c 100644 --- a/inc/hgl/type/ResManage.h +++ b/inc/hgl/type/ResManage.h @@ -27,7 +27,7 @@ namespace hgl _Map items; - void ReleaseBySerial(int,bool); + uint ReleaseBySerial(int,bool); protected: @@ -49,8 +49,8 @@ namespace hgl virtual bool ValueExist(T *); ///<确认这个数据是否存在 virtual bool GetKeyByValue(T *,F *,uint *,bool inc_ref_count=false); ///<取得一个数据的Key和引用次数 - virtual void Release(const F &,bool zero_clear=false); ///<释放一个数据 - virtual void Release(T *,bool zero_clear=false); ///<释放一个数据 + virtual uint Release(const F &,bool zero_clear=false); ///<释放一个数据 + virtual uint Release(T *,bool zero_clear=false); ///<释放一个数据 };//template class ResManage /**