//************************************************************************************** // Filename: StAllocThrowDisable.h // Part of Contextual Menu Workshop by Abracode Inc. // http://free.abracode.com/cmworkshop/ // Copyright © 2001-2003 Abracode, Inc. All rights reserved. // // Description: stack based disabler of bad alloc throws // use in environemnt where "new" throws are normally enabled // but you want them to be disabled for some code fragment // //************************************************************************************** // Revision History: // Tuesday, May 29, 2001 - Original //************************************************************************************** #ifndef _H_StAllocThrowEnable #define _H_StAllocThrowEnable #pragma once #if defined(__MWERKS__) #if __MWERKS__ >= 0x2100 // >= Pro3 //OK #else #error CodeWarrior version too old. #endif #else #error Unsupported compiler. #endif namespace std { extern char __throws_bad_alloc; } class StAllocThrowDisable { public: StAllocThrowDisable() { mPrevState = std::__throws_bad_alloc; std::__throws_bad_alloc = FALSE; } virtual ~StAllocThrowDisable() { std::__throws_bad_alloc = mPrevState; } protected: char mPrevState; }; #endif //_H_StAllocThrowEnable