From: <ric...@us...> - 2011-09-07 22:51:23
|
Revision: 1096 http://loki-lib.svn.sourceforge.net/loki-lib/?rev=1096&view=rev Author: rich_sposato Date: 2011-09-07 22:51:17 +0000 (Wed, 07 Sep 2011) Log Message: ----------- Added code to support test of bug 3224518. Modified Paths: -------------- trunk/test/SmartPtr/base.h Modified: trunk/test/SmartPtr/base.h =================================================================== --- trunk/test/SmartPtr/base.h 2011-09-07 22:50:38 UTC (rev 1095) +++ trunk/test/SmartPtr/base.h 2011-09-07 22:51:17 UTC (rev 1096) @@ -1,12 +1,12 @@ //////////////////////////////////////////////////////////////////////////////// // Test program for The Loki Library // Copyright (c) 2006 Richard Sposato -// Permission to use, copy, modify, distribute and sell this software for any -// purpose is hereby granted without fee, provided that the above copyright -// notice appear in all copies and that both that copyright notice and this +// Permission to use, copy, modify, distribute and sell this software for any +// purpose is hereby granted without fee, provided that the above copyright +// notice appear in all copies and that both that copyright notice and this // permission notice appear in supporting documentation. -// The authors make no representations about the -// suitability of this software for any purpose. It is provided "as is" +// The authors make no representations about the +// suitability of this software for any purpose. It is provided "as is" // without express or implied warranty. //////////////////////////////////////////////////////////////////////////////// @@ -20,7 +20,7 @@ class BaseClass { public: - BaseClass( void ) + BaseClass( void ) : m_refCount( 1 ) { s_constructions++; } @@ -31,8 +31,14 @@ } // These 2 functions are so we can pretend we have a COM object. - void AddRef( void ) {} - void Release( void ) {} + void AddRef( void ) { ++m_refCount; } + void Release( void ) + { + assert( 0 < m_refCount ); + --m_refCount; + if ( 0 == m_refCount ) + delete this; + } // This function is used only for the DeepCopy policy. virtual BaseClass * Clone( void ) const @@ -75,6 +81,8 @@ static unsigned int s_constructions; static unsigned int s_destructions; + + unsigned int m_refCount; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |