From: Luke Dashjr Date: Fri, 23 Dec 2011 15:09:13 +0000 (-0500) Subject: Merge branch '0.5.0.x' into 0.5.x X-Git-Tag: v0.4.0-unstable~129^2~1^2~18^2~10^2~37 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=961cf14ab3e0d16bcecdb64717accd088a0d00aa;hp=-c;p=novacoin.git Merge branch '0.5.0.x' into 0.5.x --- 961cf14ab3e0d16bcecdb64717accd088a0d00aa diff --combined src/util.h index 1ef0e6f,bcb9027..dcf060e --- a/src/util.h +++ b/src/util.h @@@ -243,20 -243,19 +243,20 @@@ public pcs = &csIn; pcs->Enter(pszName, pszFile, nLine); } + + operator bool() const + { + return true; + } + ~CCriticalBlock() { pcs->Leave(); } }; -// WARNING: This will catch continue and break! -// break is caught with an assertion, but there's no way to detect continue. -// I'd rather be careful than suffer the other more error prone syntax. -// The compiler will optimise away all this loop junk. #define CRITICAL_BLOCK(cs) \ - for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by CRITICAL_BLOCK!" && !fcriticalblockonce)), fcriticalblockonce=false) \ - for (CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__); fcriticalblockonce; fcriticalblockonce=false) + if (CCriticalBlock criticalblock = CCriticalBlock(cs, #cs, __FILE__, __LINE__)) class CTryCriticalBlock { @@@ -268,12 -267,6 +268,12 @@@ public { pcs = (csIn.TryEnter(pszName, pszFile, nLine) ? &csIn : NULL); } + + operator bool() const + { + return Entered(); + } + ~CTryCriticalBlock() { if (pcs) @@@ -281,21 -274,22 +281,25 @@@ pcs->Leave(); } } - bool Entered() { return pcs != NULL; } + bool Entered() const { return pcs != NULL; } }; #define TRY_CRITICAL_BLOCK(cs) \ - for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by TRY_CRITICAL_BLOCK!" && !fcriticalblockonce)), fcriticalblockonce=false) \ - for (CTryCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__); fcriticalblockonce && (fcriticalblockonce = criticalblock.Entered()); fcriticalblockonce=false) + if (CTryCriticalBlock criticalblock = CTryCriticalBlock(cs, #cs, __FILE__, __LINE__)) + +// This is exactly like std::string, but with a custom allocator. +// (secure_allocator<> is defined in serialize.h) +typedef std::basic_string, secure_allocator > SecureString; + // This is exactly like std::string, but with a custom allocator. + // (secure_allocator<> is defined in serialize.h) + typedef std::basic_string, secure_allocator > SecureString; +