forked from boostorg/unordered
Merge in latest unordered developments (revisions 42607-42611).
[SVN r42612]
This commit is contained in:
@@ -192,18 +192,7 @@ namespace exception
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -214,7 +203,22 @@ namespace exception
|
||||
int tag_;
|
||||
};
|
||||
|
||||
typedef std::map<memory_area, memory_track, std::less<memory_area>,
|
||||
// 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,
|
||||
test::malloc_allocator<std::pair<memory_area const, memory_track> > >
|
||||
allocated_memory_type;
|
||||
allocated_memory_type allocated_memory;
|
||||
@@ -270,7 +274,7 @@ namespace exception
|
||||
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 * size));
|
||||
if(pos == allocated_memory.end()) {
|
||||
BOOST_ERROR("Deallocating unknown pointer.");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user