In almost every book about C++ I read, they
say that, if 'new' fails, it returnes a pointer to
NULL or they throw an exception (std:.bad_alloc).
Unfortunately, I compiled my application on a
outdated woody snapshot with gcc 2.95.3 and
I was not able to prevent my code from crashing.
When the system memory was exhausted, the
programm was aborted and a message 'out of
memory' appeared on the console.
I encapsulated the dangerous code in a 'try'
block and I catched 'std::bad_alloc' as well
as every other exception (catch(...)) but this
didn't help.
Testing the pointer if it is NULL didn't help
either.
Is there a third way of what could happen
if 'new' fails? I only know the NULL- and the
exception thing.
On my machine at home (2.95.4, woody)
an exception is thrown and can be caugth.
But on that other woody machine, I couldn't
handle this situation.
Martin
--
http://www.martinhenne.de
http://www.aachenprogrammingclub.de
http://apcstudio.sf.net