diff options
author | lloyd <[email protected]> | 2009-06-04 16:06:59 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-06-04 16:06:59 +0000 |
commit | 9de911f55808e84e8d14efbecf8379c25afb9d50 (patch) | |
tree | da2d3825ed58833ae40fc0ffa3e704473aafd0e0 /src/alloc/mem_pool/mem_pool.cpp | |
parent | a96eae0b3394b64aea544f9f0ce4664d3b4a5c58 (diff) | |
parent | 3afb86663583b982e1eab8f46d07fc3d51260602 (diff) |
propagate from branch 'net.randombit.botan' (head 6a746ccf1e957dba703e65372050a7bd4d6b117d)
to branch 'net.randombit.botan.c++0x' (head f54bb7b391eb3b71f380a68ddd460debdc31545d)
Diffstat (limited to 'src/alloc/mem_pool/mem_pool.cpp')
-rw-r--r-- | src/alloc/mem_pool/mem_pool.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/alloc/mem_pool/mem_pool.cpp b/src/alloc/mem_pool/mem_pool.cpp index 38e0c3285..a3858add6 100644 --- a/src/alloc/mem_pool/mem_pool.cpp +++ b/src/alloc/mem_pool/mem_pool.cpp @@ -109,7 +109,7 @@ void Pooling_Allocator::Memory_Block::free(void* ptr, u32bit blocks) throw() /* * Pooling_Allocator Constructor */ -Pooling_Allocator::Pooling_Allocator(Mutex* m) : mutex(m) +Pooling_Allocator::Pooling_Allocator() { last_used = blocks.begin(); } @@ -119,7 +119,6 @@ Pooling_Allocator::Pooling_Allocator(Mutex* m) : mutex(m) */ Pooling_Allocator::~Pooling_Allocator() { - delete mutex; if(blocks.size()) throw Invalid_State("Pooling_Allocator: Never released memory"); } @@ -129,7 +128,7 @@ Pooling_Allocator::~Pooling_Allocator() */ void Pooling_Allocator::destroy() { - Mutex_Holder lock(mutex); + std::lock_guard<std::mutex> lock(mutex); blocks.clear(); @@ -146,7 +145,7 @@ void* Pooling_Allocator::allocate(u32bit n) const u32bit BITMAP_SIZE = Memory_Block::bitmap_size(); const u32bit BLOCK_SIZE = Memory_Block::block_size(); - Mutex_Holder lock(mutex); + std::lock_guard<std::mutex> lock(mutex); if(n <= BITMAP_SIZE * BLOCK_SIZE) { @@ -183,7 +182,7 @@ void Pooling_Allocator::deallocate(void* ptr, u32bit n) if(ptr == 0 && n == 0) return; - Mutex_Holder lock(mutex); + std::lock_guard<std::mutex> lock(mutex); if(n > BITMAP_SIZE * BLOCK_SIZE) dealloc_block(ptr, n); |