$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: daniel_james_at_[hidden]
Date: 2008-01-07 16:05:42
Author: danieljames
Date: 2008-01-07 16:05:42 EST (Mon, 07 Jan 2008)
New Revision: 42587
URL: http://svn.boost.org/trac/boost/changeset/42587
Log:
Fix a bug which was causing the memory area stuff to fail.
I should probably try to be less clever and use memory area's lower
bounds as the key, and do the extra work required to get that working.
Text files modified: 
   trunk/libs/unordered/test/objects/test.hpp |    42 +++++++++++++++++++++------------------ 
   1 files changed, 23 insertions(+), 19 deletions(-)
Modified: trunk/libs/unordered/test/objects/test.hpp
==============================================================================
--- trunk/libs/unordered/test/objects/test.hpp	(original)
+++ trunk/libs/unordered/test/objects/test.hpp	2008-01-07 16:05:42 EST (Mon, 07 Jan 2008)
@@ -215,18 +215,7 @@
                 memory_area(void const* s, void const* e)
                     : start(s), end(e)
                 {
-                }
-
-                // This is a bit dodgy as it defines overlapping
-                // areas as 'equal', so this isn't a total ordering.
-                // But it is for non-overlapping memory regions - which
-                // is what'll be stored.
-                //
-                // All searches will be for areas entirely contained by
-                // a member of the set - so it should find the area that contains
-                // the region that is searched for.
-                bool operator<(memory_area const& other) const {
-                    return end < other.start;
+                    BOOST_ASSERT(start != end);
                 }
             };
 
@@ -239,7 +228,22 @@
                 int tag_;
             };
 
-            typedef std::map<memory_area, memory_track> allocated_memory_type;
+            // This is a bit dodgy as it defines overlapping
+            // areas as 'equal', so this isn't a total ordering.
+            // But it is for non-overlapping memory regions - which
+            // is what'll be stored.
+            //
+            // All searches will be for areas entirely contained by
+            // a member of the set - so it should find the area that contains
+            // the region that is searched for.
+
+            struct memory_area_compare {
+                bool operator()(memory_area const& x, memory_area const& y) const {
+                    return x.end <= y.start;
+                }
+            };
+
+            typedef std::map<memory_area, memory_track, memory_area_compare> allocated_memory_type;
             allocated_memory_type allocated_memory;
             unsigned int count_allocators = 0;
             unsigned int count_allocations = 0;
@@ -293,12 +297,12 @@
         void track_deallocate(void* ptr, std::size_t n, std::size_t size, int tag)
         {
             allocated_memory_type::iterator pos
-                = allocated_memory.find(memory_area(ptr, ptr));
+                = allocated_memory.find(memory_area(ptr, (char*) ptr + n));
             if(pos == allocated_memory.end()) {
                 BOOST_ERROR("Deallocating unknown pointer.");
             } else {
                 BOOST_TEST(pos->first.start == ptr);
-                BOOST_TEST(pos->first.end == (char*) ptr + n * size);
+                BOOST_TEST(pos->first.end == (char*) ptr + n * size - 1);
                 BOOST_TEST(pos->second.tag_ == tag);
                 BOOST_TEST(pos->second.constructed_ == 0);
                 allocated_memory.erase(pos);
@@ -307,10 +311,10 @@
             if(count_allocations > 0) --count_allocations;
         }
 
-        void track_construct(void* ptr, std::size_t /*size*/, int tag)
+        void track_construct(void* ptr, std::size_t size, int tag)
         {
             allocated_memory_type::iterator pos
-                = allocated_memory.find(memory_area(ptr, ptr));
+                = allocated_memory.find(memory_area(ptr, (char*) ptr + size));
             if(pos == allocated_memory.end()) {
                 BOOST_ERROR("Constructing unknown pointer.");
             }
@@ -321,10 +325,10 @@
             ++count_constructions;
         }
 
-        void track_destroy(void* ptr, std::size_t /*size*/, int tag)
+        void track_destroy(void* ptr, std::size_t size, int tag)
         {
             allocated_memory_type::iterator pos
-                = allocated_memory.find(memory_area(ptr, ptr));
+                = allocated_memory.find(memory_area(ptr, (char*) ptr + size));
             if(pos == allocated_memory.end())
                 BOOST_ERROR("Destroying unknown pointer.");
             else {