$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r71408 - in sandbox/shifted_ptr/boost: . detail
From: phil_at_[hidden]
Date: 2011-04-21 23:56:53
Author: pbouchard
Date: 2011-04-21 23:56:50 EDT (Thu, 21 Apr 2011)
New Revision: 71408
URL: http://svn.boost.org/trac/boost/changeset/71408
Log:
* Fixed important bug in destructor
Text files modified: 
   sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp |    41 +-------------------------------------- 
   sandbox/shifted_ptr/boost/shifted_ptr.hpp             |    20 +++++++-----------                      
   2 files changed, 10 insertions(+), 51 deletions(-)
Modified: sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp
==============================================================================
--- sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp	(original)
+++ sandbox/shifted_ptr/boost/detail/sh_owned_base_nt.hpp	2011-04-21 23:56:50 EDT (Thu, 21 Apr 2011)
@@ -70,43 +70,7 @@
         Pool where all pointee objects are allocated and tracks memory blocks for later enlisting & marking the @c set the pointee object belongs to.
 */
 
-struct malloc_pool
-{
-	std::set<void *> alloc;
-	
-	void * ordered_malloc(size_t n)
-	{
-		void * p = malloc(n);
-		
-		alloc.insert(p);
-		
-		return p;
-	}
-
-	void ordered_free(void * p, size_t n)
-	{
-		std::set<void *>::iterator i = alloc.find(p);
-		
-		if (i == alloc.end())
-			abort();
-		else
-			alloc.erase(i);
-		
-		free(p);
-	}
-	
-	bool is_from(void * p)
-	{
-		static char * upper = (char *) sbrk(0);
-		static char * lower = upper - 0x100000;
-
-		return lower <= p && p < upper;
-	}
-};
-
-
-//struct pool : boost::pool<>
-struct pool : malloc_pool
+struct pool : boost::pool<>
 {
         typedef std::list< numeric::interval<long>, fast_pool_allocator< numeric::interval<long> > > pool_lii;	/**< Syntax helper. */
 
@@ -121,8 +85,7 @@
                 Initialization of a pool instance.
         */
         
-//    pool() : boost::pool<>(1)
-    pool()
+    pool() : boost::pool<>(1)
     {
         plii_.reset(new pool_lii());
     }
Modified: sandbox/shifted_ptr/boost/shifted_ptr.hpp
==============================================================================
--- sandbox/shifted_ptr/boost/shifted_ptr.hpp	(original)
+++ sandbox/shifted_ptr/boost/shifted_ptr.hpp	2011-04-21 23:56:50 EDT (Thu, 21 Apr 2011)
@@ -69,6 +69,7 @@
     static fast_pool_allocator<set> pool_;			/**< Pool where all @c set s are allocated. */
 
 public:
+	bool destroy_;									/**< Destruction sequence initiated. */
     intrusive_list::node tag_;						/**< Tag used to enlist to @c set::includes_ . */
 
 
@@ -76,7 +77,7 @@
                 Initialization of a single @c set .
         */
         
-    set() : count_(1), redir_(this)
+    set() : count_(1), redir_(this), destroy_(false)
     {
         includes_.push_back(& tag_);
     }
@@ -94,12 +95,11 @@
 
         if (-- p->count_ == 0)
         {
+			p->destroy_ = true;
             for (intrusive_list::iterator<owned_base, & owned_base::set_tag_> i; i = p->elements_.begin(), i != p->elements_.end(); )
-            {
-                i->add_ref_copy();
                 delete &* i;
-            }
-                
+			p->destroy_ = false;
+            
             for (intrusive_list::iterator<set, & set::tag_> i = p->includes_.begin(), j; j = i, i != p->includes_.end(); i = j)
                         { 
                                 ++ j;
@@ -359,14 +359,10 @@
 
         ~shifted_ptr()
         {
-			std::set<void *>::iterator i = owned_base::pool_.alloc.find(base::po_);
-		
-			if (i == owned_base::pool_.alloc.end())
-				abort();
-			else
-				owned_base::pool_.alloc.erase(i);
-
             release(true);
+			
+			if (ps_->destroy_)
+				base::po_ = 0;
         }
 
     private: