diff options
author | lloyd <[email protected]> | 2009-11-02 12:12:40 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-11-02 12:12:40 +0000 |
commit | b8658279904708d0690e473fb85942d5da23d2fc (patch) | |
tree | 65528378bd0089287ca0927a13a6e0a012f7bc78 /src/alloc/mem_pool/mem_pool.cpp | |
parent | 6b617a55bd02bcc4fdb6f76af92e0cb65fd838a2 (diff) | |
parent | 92f31b22dfe2aa1b2bde84cbaf4ce7365fa4ec68 (diff) |
propagate from branch 'net.randombit.botan' (head 2773c2310e8c0a51975987a2dd6c5824c8d43882)
to branch 'net.randombit.botan.c++0x' (head f13cf5d7e89706c882604299b508f356c20aae3a)
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 e30a7b98a..02a12d6a5 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) /* * 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); |