From 057d0b6eeb93c4f15c8c172fc7f991bb8654c4d2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 12 Mar 2014 10:00:24 -0400 Subject: finally put this patch into git, where it belong --- tools/boost-ptr-debug.patch | 275 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 275 insertions(+) create mode 100644 tools/boost-ptr-debug.patch (limited to 'tools/boost-ptr-debug.patch') diff --git a/tools/boost-ptr-debug.patch b/tools/boost-ptr-debug.patch new file mode 100644 index 0000000000..d5c49d96ad --- /dev/null +++ b/tools/boost-ptr-debug.patch @@ -0,0 +1,275 @@ +--- shared_ptr.hpp.ORIG 2009-11-25 15:30:43.000000000 -0500 ++++ shared_ptr.hpp 2009-12-26 10:04:49.000000000 -0500 +@@ -55,6 +55,13 @@ + # pragma warning(disable:4284) // odd return type for operator-> + #endif + ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++void boost_debug_shared_ptr_operator_equals (void const *, void const *, int, void const*, int); ++void boost_debug_shared_ptr_reset (void const *, void const *, int, void const*, int); ++void boost_debug_shared_ptr_destructor (void const *, void const *, int); ++void boost_debug_shared_ptr_constructor (void const *, void const *, int); ++#endif ++ + namespace boost + { + +@@ -181,12 +188,31 @@ + + shared_ptr(): px(0), pn() // never throws in 1.30+ + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif ++ } ++ ++ ~shared_ptr() ++ { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_destructor (this, get(), use_count()); ++#endif ++ } ++ ++ shared_ptr(const shared_ptr& r ) : px (r.px), pn (r.pn) { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + template + explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete + { + boost::detail::sp_enable_shared_from_this( this, p, p ); ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + // +@@ -197,7 +223,10 @@ + + template shared_ptr(Y * p, D d): px(p), pn(p, d) + { +- boost::detail::sp_enable_shared_from_this( this, p, p ); ++ boost::detail::sp_enable_shared_from_this( this, p, p ); ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + // As above, but with allocator. A's copy constructor shall not throw. +@@ -205,6 +234,9 @@ + template shared_ptr( Y * p, D d, A a ): px( p ), pn( p, d, a ) + { + boost::detail::sp_enable_shared_from_this( this, p, p ); ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + // generated copy constructor, destructor are fine +@@ -214,6 +246,9 @@ + { + // it is now safe to copy r.px, as pn(r.pn) did not throw + px = r.px; ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + template +@@ -223,6 +258,9 @@ + { + px = r.px; + } ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + template +@@ -237,22 +275,34 @@ + #endif + : px( r.px ), pn( r.pn ) // never throws + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + // aliasing + template< class Y > + shared_ptr( shared_ptr const & r, T * p ): px( p ), pn( r.pn ) // never throws + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + template + shared_ptr(shared_ptr const & r, boost::detail::static_cast_tag): px(static_cast(r.px)), pn(r.pn) + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + template + shared_ptr(shared_ptr const & r, boost::detail::const_cast_tag): px(const_cast(r.px)), pn(r.pn) + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + template +@@ -262,6 +312,9 @@ + { + pn = boost::detail::shared_count(); + } ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + template +@@ -271,6 +324,9 @@ + { + boost::throw_exception(std::bad_cast()); + } ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + #ifndef BOOST_NO_AUTO_PTR +@@ -281,6 +337,9 @@ + Y * tmp = r.get(); + pn = boost::detail::shared_count(r); + boost::detail::sp_enable_shared_from_this( this, tmp, tmp ); ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + #if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) +@@ -291,6 +350,9 @@ + typename Ap::element_type * tmp = r.get(); + pn = boost::detail::shared_count( r ); + boost::detail::sp_enable_shared_from_this( this, tmp, tmp ); ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + +@@ -302,6 +364,9 @@ + + shared_ptr & operator=( shared_ptr const & r ) // never throws + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_operator_equals (this, get(), use_count(), r.get(), r.use_count()); ++#endif + this_type(r).swap(*this); + return *this; + } +@@ -311,6 +376,9 @@ + template + shared_ptr & operator=(shared_ptr const & r) // never throws + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_operator_equals (this, get(), use_count(), r.get(), r.use_count()); ++#endif + this_type(r).swap(*this); + return *this; + } +@@ -322,6 +390,9 @@ + template + shared_ptr & operator=( std::auto_ptr & r ) + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_operator_equals (this, get(), use_count(), r.get(), r.use_count()); ++#endif + this_type(r).swap(*this); + return *this; + } +@@ -348,6 +419,9 @@ + { + pn.swap( r.pn ); + r.px = 0; ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + template +@@ -364,10 +438,16 @@ + { + pn.swap( r.pn ); + r.px = 0; ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_constructor (this, px, use_count()); ++#endif + } + + shared_ptr & operator=( shared_ptr && r ) // never throws + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_operator_equals (this, get(), use_count(), r.get(), r.use_count()); ++#endif + this_type( std::move( r ) ).swap( *this ); + return *this; + } +@@ -375,6 +455,9 @@ + template + shared_ptr & operator=( shared_ptr && r ) // never throws + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_operator_equals (this, get(), use_count(), r.get(), r.use_count()); ++#endif + this_type( std::move( r ) ).swap( *this ); + return *this; + } +@@ -383,27 +466,42 @@ + + void reset() // never throws in 1.30+ + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_reset (this, get(), use_count(), 0, 0); ++#endif + this_type().swap(*this); + } + + template void reset(Y * p) // Y must be complete + { + BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_reset (this, get(), use_count(), p, 0); ++#endif + this_type(p).swap(*this); + } + + template void reset( Y * p, D d ) + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_reset (this, get(), use_count(), p, 0); ++#endif + this_type( p, d ).swap( *this ); + } + + template void reset( Y * p, D d, A a ) + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_reset (this, get(), use_count(), p, 0); ++#endif + this_type( p, d, a ).swap( *this ); + } + + template void reset( shared_ptr const & r, T * p ) + { ++#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS ++ boost_debug_shared_ptr_reset (this, get(), use_count(), r.get(), r.use_count()); ++#endif + this_type( r, p ).swap( *this ); + } + -- cgit v1.2.3