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 /**