diff options
author | lloyd <[email protected]> | 2007-04-25 23:29:56 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2007-04-25 23:29:56 +0000 |
commit | 461d575c67fd54f3ad9146720b44242e53aa81bd (patch) | |
tree | acdfb87e14f5c349efe9e81675a051b810dafd37 | |
parent | 0466f2522f6bfda4527507320257fc4b1339ba55 (diff) | |
parent | 454d4d7edc20c10ed7219f45698486902bba4880 (diff) |
propagate from branch 'net.randombit.botan.stable' (head 8a2b79c64a13d3f70b0211d4f985a678951a9663)
to branch 'net.randombit.botan' (head 677686443a5bb53b03d147999947448a9dc2679a)
-rw-r--r-- | include/mem_pool.h | 7 | ||||
-rw-r--r-- | src/mem_pool.cpp | 12 |
2 files changed, 6 insertions, 13 deletions
diff --git a/include/mem_pool.h b/include/mem_pool.h index 199ee47b6..435acd5b0 100644 --- a/include/mem_pool.h +++ b/include/mem_pool.h @@ -46,9 +46,12 @@ class Pooling_Allocator : public Allocator byte* alloc(u32bit) throw(); void free(void*, u32bit) throw(); - bool operator<(const void*) const; bool operator<(const Memory_Block& other) const - { return (buffer < other.buffer); } + { + if(buffer < other.buffer && other.buffer < buffer_end) + return false; + return (buffer < other.buffer); + } private: typedef u64bit bitmap_type; static const u32bit BITMAP_SIZE = 8 * sizeof(bitmap_type); diff --git a/src/mem_pool.cpp b/src/mem_pool.cpp index 67da88a14..faf399ec6 100644 --- a/src/mem_pool.cpp +++ b/src/mem_pool.cpp @@ -42,16 +42,6 @@ Pooling_Allocator::Memory_Block::Memory_Block(void* buf) } /************************************************* -* Compare a Memory_Block with a void pointer * -*************************************************/ -inline bool Pooling_Allocator::Memory_Block::operator<(const void* other) const - { - if(buffer <= other && other < buffer_end) - return false; - return (buffer < other); - } - -/************************************************* * See if ptr is contained by this block * *************************************************/ bool Pooling_Allocator::Memory_Block::contains(void* ptr, @@ -207,7 +197,7 @@ void Pooling_Allocator::deallocate(void* ptr, u32bit n) const u32bit block_no = round_up(n, BLOCK_SIZE) / BLOCK_SIZE; std::vector<Memory_Block>::iterator i = - std::lower_bound(blocks.begin(), blocks.end(), ptr); + std::lower_bound(blocks.begin(), blocks.end(), Memory_Block(ptr)); if(i == blocks.end() || !i->contains(ptr, block_no)) throw Invalid_State("Pointer released to the wrong allocator"); |