aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-07-13 13:33:41 +0000
committerlloyd <[email protected]>2012-07-13 13:33:41 +0000
commit9ae7b4526bc0404ae3241f55d27a4537bb108c0b (patch)
treedfab2bf069fb83c7ecce754a74ba0d1d7d2a4536 /src
parent8869d23625e774bedcd0921be2d3828592403290 (diff)
Use uintptr_t in ptr_in_pool instead of size_t as uintptr_t is now
standard in C++11 and makes more sense than size_t Make m_poolsize a const. There is no real reason to reset it to zero if a failure occurs since a) we are throwing an exception anyway and b) we check for !m_pool first thing.
Diffstat (limited to 'src')
-rw-r--r--src/alloc/locking_allocator/locking_allocator.cpp7
-rw-r--r--src/alloc/locking_allocator/locking_allocator.h3
2 files changed, 4 insertions, 6 deletions
diff --git a/src/alloc/locking_allocator/locking_allocator.cpp b/src/alloc/locking_allocator/locking_allocator.cpp
index 575a5f962..d1a1b9c72 100644
--- a/src/alloc/locking_allocator/locking_allocator.cpp
+++ b/src/alloc/locking_allocator/locking_allocator.cpp
@@ -45,8 +45,8 @@ size_t mlock_limit()
bool ptr_in_pool(const void* pool_ptr, size_t poolsize,
const void* buf_ptr, size_t bufsize)
{
- const size_t pool = reinterpret_cast<size_t>(pool_ptr);
- const size_t buf = reinterpret_cast<size_t>(buf_ptr);
+ const uintptr_t pool = reinterpret_cast<uintptr_t>(pool_ptr);
+ const uintptr_t buf = reinterpret_cast<uintptr_t>(buf_ptr);
if(buf < pool || buf >= pool + poolsize)
return false;
@@ -227,7 +227,6 @@ mlock_allocator::mlock_allocator() :
if(m_pool == static_cast<byte*>(MAP_FAILED))
{
m_pool = nullptr;
- m_poolsize = 0;
throw std::runtime_error("Failed to mmap locking_allocator pool");
}
@@ -237,7 +236,6 @@ mlock_allocator::mlock_allocator() :
{
::munmap(m_pool, m_poolsize);
m_pool = nullptr;
- m_poolsize = 0;
throw std::runtime_error("Failed to lock pool in memory");
}
@@ -253,7 +251,6 @@ mlock_allocator::~mlock_allocator()
::munlock(m_pool, m_poolsize);
::munmap(m_pool, m_poolsize);
m_pool = nullptr;
- m_poolsize = 0;
}
}
diff --git a/src/alloc/locking_allocator/locking_allocator.h b/src/alloc/locking_allocator/locking_allocator.h
index 4b5e25e03..3bebea5f2 100644
--- a/src/alloc/locking_allocator/locking_allocator.h
+++ b/src/alloc/locking_allocator/locking_allocator.h
@@ -32,8 +32,9 @@ class BOTAN_DLL mlock_allocator
~mlock_allocator();
+ const size_t m_poolsize;
+
std::mutex m_mutex;
- size_t m_poolsize;
std::vector<std::pair<size_t, size_t>> m_freelist;
byte* m_pool;
};