summaryrefslogtreecommitdiff
path: root/lib/common/Guards.h
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-06-10 19:46:17 +0000
committerChris Wilson <chris+github@qwirx.com>2015-06-10 19:46:17 +0000
commitd7058db9ea03c1d58e73ea1088b5ff88ff0301ee (patch)
treea903717ec90baa35e54ea9adb11691ac3686ccae /lib/common/Guards.h
parentcc5787c423774dd709eab97511fd8a2fbf3d31d2 (diff)
Allow MemoryBlockGuard to guard a block passed in (already malloced).
Diffstat (limited to 'lib/common/Guards.h')
-rw-r--r--lib/common/Guards.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/common/Guards.h b/lib/common/Guards.h
index 7ca1fbb6..364252a5 100644
--- a/lib/common/Guards.h
+++ b/lib/common/Guards.h
@@ -77,7 +77,16 @@ class MemoryBlockGuard
{
public:
MemoryBlockGuard(int BlockSize)
- : mpBlock(::malloc(BlockSize))
+ : mpBlock(::malloc(BlockSize))
+ {
+ if(mpBlock == 0)
+ {
+ throw std::bad_alloc();
+ }
+ }
+
+ MemoryBlockGuard(void *pBlock)
+ : mpBlock(pBlock)
{
if(mpBlock == 0)
{