aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc
diff options
context:
space:
mode:
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());
}