> Subject: RE: Problems with new[] > From: "Russell K Bulmer" <[EMAIL PROTECTED]> > Date: Fri, 18 Oct 2002 12:33:03 +0100 > X-Message-Number: 7 > > >I found out, that the operator new just fails and quits the program without > any comment if > >there is not enough space to create an (C++) object. > > > >Can you give me some suggestions how to solve this? > >I dont want to wrap every new[] into ErrTry..ErrCatch in my code. A single > function that returns > >the object or NULL would be nice. > > > >Is there some kind wrapper-function to create an object via MemPtrNew() ? > >(Anyway, if you think Exceptions are the ultimate way, write me.) > > > > According to Stroustrup when new fails to get sufficient memory it will > throw a bad_alloc exception, is this not happening? > > Skimming through the CW headers at speed, it looks like new is doing exactly > this. However... there's some checking in there to avoid throwing > exceptions, and I assume this is for when you've got C++ exceptions turned > off in CW. So if you don't need C++ exceptions you could turn them off and > get NULL returned for failed news. (I think) > Not really, when you switch exceptions off new works exactly the same (not enough memory will quit program) but there is no way (or I have found none) to catch it.
> > Cheers > Russell -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
