[Botan-devel] Re: botan-devel Digest, Vol 30, Issue 6
Jack Lloyd
lloyd at randombit.net
Tue Jun 19 12:55:40 EDT 2007
On Tue, Jun 19, 2007 at 12:37:44PM -0400, John Proffer wrote:
> Thanks for the quick response. Sorry, I should have mentioned, that
> this error is with botan 1.6.2.
> I had to move #undef _DEBUG in mem_pool.cpp to above the includes,
> before it would compile with /MTd without errors. I have Visual Studio
> 2005 Professional.
OK, could you try the attached patch and let me know if it helps?
-Jack
-------------- next part --------------
#
# old_revision [4d0953766febe64e617d8a7598c673915345e235]
#
# patch "include/mem_pool.h"
# from [192b53b7d05827d947e00d2814598e56ba92fa9e]
# to [5c7868d373529114f14223b4cb7533ffa0b7133e]
#
# patch "src/mem_pool.cpp"
# from [c5183d5071d05861650892a85af9a3aac95221c5]
# to [0a6884046e969b8d9b409a276adce4474ca3b921]
#
============================================================
--- include/mem_pool.h 192b53b7d05827d947e00d2814598e56ba92fa9e
+++ include/mem_pool.h 5c7868d373529114f14223b4cb7533ffa0b7133e
@@ -46,9 +46,12 @@ class Pooling_Allocator : public Allocat
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);
============================================================
--- src/mem_pool.cpp c5183d5071d05861650892a85af9a3aac95221c5
+++ src/mem_pool.cpp 0a6884046e969b8d9b409a276adce4474ca3b921
@@ -42,16 +42,6 @@ Pooling_Allocator::Memory_Block::Memory_
}
/*************************************************
-* 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*
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");
More information about the botan-devel
mailing list