From: malaterre Date: Wed, 26 Oct 2005 15:41:29 +0000 (+0000) Subject: ENH: If Ref count is -1, also delete the object (in case someone call twice a ->Delete() X-Git-Tag: OpenJPEG.Version1.2~141 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=aa691517fbdb02c3daa7e6095ca5e1bbca3e5ed3;p=gdcm.git ENH: If Ref count is -1, also delete the object (in case someone call twice a ->Delete() --- diff --git a/src/gdcmRefCounter.h b/src/gdcmRefCounter.h index ee664d79..ce9858ac 100644 --- a/src/gdcmRefCounter.h +++ b/src/gdcmRefCounter.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmRefCounter.h,v $ Language: C++ - Date: $Date: 2005/10/23 15:06:34 $ - Version: $Revision: 1.7 $ + Date: $Date: 2005/10/26 15:41:29 $ + Version: $Revision: 1.8 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -37,33 +37,26 @@ public: // Allocator / Unallocator /// \brief Delete the object /// \remarks The object is deleted only if its reference counting is to zero - inline void Delete(void) - { - Unregister(); - } + void Delete() { Unregister(); } // Reference count /// \brief Register the object /// \remarks It increments the reference counting - inline void Register(void) - { - RefCount++; - } + void Register() { RefCount++; } + /// \brief Unregister the object /// \remarks It decrements the reference counting - inline void Unregister(void) + void Unregister() { RefCount--; - if(RefCount==0) - { + if(RefCount<=0) delete this; - } } /// \brief Get the reference counting /// \return Reference count - inline const unsigned long &GetRefCount(void) const + const unsigned long &GetRefCount() const { - return(RefCount); + return RefCount; } protected: