aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc/mem_pool
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc/mem_pool')
-rw-r--r--src/alloc/mem_pool/mem_pool.cpp9
-rw-r--r--src/alloc/mem_pool/mem_pool.h6
2 files changed, 7 insertions, 8 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);
diff --git a/src/alloc/mem_pool/mem_pool.h b/src/alloc/mem_pool/mem_pool.h
index a57800972..871f135bd 100644
--- a/src/alloc/mem_pool/mem_pool.h
+++ b/src/alloc/mem_pool/mem_pool.h
@@ -10,7 +10,7 @@
#include <botan/allocate.h>
#include <botan/exceptn.h>
-#include <botan/mutex.h>
+#include <mutex>
#include <utility>
#include <vector>
@@ -27,7 +27,7 @@ class BOTAN_DLL Pooling_Allocator : public Allocator
void destroy();
- Pooling_Allocator(Mutex*);
+ Pooling_Allocator();
~Pooling_Allocator();
private:
void get_more_core(u32bit);
@@ -66,7 +66,7 @@ class BOTAN_DLL Pooling_Allocator : public Allocator
std::vector<Memory_Block> blocks;
std::vector<Memory_Block>::iterator last_used;
std::vector<std::pair<void*, u32bit> > allocated;
- Mutex* mutex;
+ std::mutex mutex;
};
}