[Box Backup-commit] COMMIT r3579 - box/trunk/lib/common

subversion at boxbackup.org subversion at boxbackup.org
Wed Jun 10 20:46:17 BST 2015


Author: chris
Date: 2015-06-10 19:46:17 +0000 (Wed, 10 Jun 2015)
New Revision: 3579

Modified:
   box/trunk/lib/common/Guards.h
Log:
Allow MemoryBlockGuard to guard a block passed in (already malloced).

Modified: box/trunk/lib/common/Guards.h
===================================================================
--- box/trunk/lib/common/Guards.h	2015-06-10 19:46:15 UTC (rev 3578)
+++ box/trunk/lib/common/Guards.h	2015-06-10 19:46:17 UTC (rev 3579)
@@ -77,7 +77,7 @@
 {
 public:
 	MemoryBlockGuard(int BlockSize)
-		: mpBlock(::malloc(BlockSize))
+	: mpBlock(::malloc(BlockSize))
 	{
 		if(mpBlock == 0)
 		{
@@ -84,6 +84,15 @@
 			throw std::bad_alloc();
 		}
 	}
+
+	MemoryBlockGuard(void *pBlock)
+	: mpBlock(pBlock)
+	{
+		if(mpBlock == 0)
+		{
+			throw std::bad_alloc();
+		}
+	}
 	
 	~MemoryBlockGuard()
 	{




More information about the Boxbackup-commit mailing list