aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-04-25 13:48:08 +0000
committerlloyd <[email protected]>2012-04-25 13:48:08 +0000
commitb72a44475d06263e1492f8913310b5f29515cba6 (patch)
tree680752dbd43999cea16851b9c196046d9e5fbd7f /src/alloc
parentedca5f211722ea6b9d99b8b5fce4603a1b9b422d (diff)
parentf14a9fdee7902ba1a4c962cfbabe29d5146e7c55 (diff)
propagate from branch 'net.randombit.botan.tls-state-machine' (head a4741cd07f50a9e1b29b0dd97c6fb8697c038ade)
to branch 'net.randombit.botan.cxx11' (head 116e5ff139c07000be431e07d3472cc8f3919b91)
Diffstat (limited to 'src/alloc')
-rw-r--r--src/alloc/alloc_mmap/mmap_mem.cpp6
-rw-r--r--src/alloc/secmem.h17
2 files changed, 13 insertions, 10 deletions
diff --git a/src/alloc/alloc_mmap/mmap_mem.cpp b/src/alloc/alloc_mmap/mmap_mem.cpp
index bdc3fcab9..b90b6d5f7 100644
--- a/src/alloc/alloc_mmap/mmap_mem.cpp
+++ b/src/alloc/alloc_mmap/mmap_mem.cpp
@@ -128,15 +128,17 @@ void MemoryMapping_Allocator::dealloc_block(void* ptr, size_t n)
const byte PATTERNS[] = { 0x00, 0xF5, 0x5A, 0xAF, 0x00 };
+ // The char* casts are for Solaris, args are void* on most other systems
+
for(size_t i = 0; i != sizeof(PATTERNS); ++i)
{
std::memset(ptr, PATTERNS[i], n);
- if(::msync((char*)ptr, n, MS_SYNC))
+ if(::msync(static_cast<char*>(ptr), n, MS_SYNC))
throw MemoryMapping_Failed("Sync operation failed");
}
- if(::munmap((char*)ptr, n))
+ if(::munmap(static_cast<char*>(ptr), n))
throw MemoryMapping_Failed("Could not unmap file");
}
diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h
index 6c8a75c44..884f2ebc0 100644
--- a/src/alloc/secmem.h
+++ b/src/alloc/secmem.h
@@ -59,14 +59,14 @@ class MemoryRegion
const T* begin() const { return buf; }
/**
- * Get a pointer to the last element in the buffer.
- * @return pointer to the last element in the buffer
+ * Get a pointer to one past the last element in the buffer.
+ * @return pointer to one past the last element in the buffer
*/
T* end() { return (buf + size()); }
/**
- * Get a constant pointer to the last element in the buffer.
- * @return constant pointer to the last element in the buffer
+ * Get a const pointer to one past the last element in the buffer.
+ * @return const pointer to one past the last element in the buffer
*/
const T* end() const { return (buf + size()); }
@@ -172,11 +172,12 @@ class MemoryRegion
* Copy constructor
* @param other the other region to copy
*/
- MemoryRegion(const MemoryRegion<T>& other)
+ MemoryRegion(const MemoryRegion<T>& other) :
+ buf(0),
+ used(0),
+ allocated(0),
+ alloc(other.alloc)
{
- buf = 0;
- used = allocated = 0;
- alloc = other.alloc;
resize(other.size());
copy(&other[0], other.size());
}