This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Can new operator return NULL ?
- From: "Peter Skvarka" <ps at softinengines dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Wed, 12 Sep 2007 22:52:45 +0200
- Subject: Can new operator return NULL ?
- Reply-to: <ps at softinengines dot com>
I am looking how to force that new operator will return NULL instead of
std::bad_alloc exception when lack of memory.
I have on the beginning of code mlockall(MCL_FUTURE); this forces malloc()
to return NULL if out of nemory,
but new operator throws exception.
I know that in Windows Visual C++ throwing new is set by chosing standard
C++ library and nonthrowing new is from main CRT,
so in VS I can choose one of these two features.
Is possible in C++ code compiled with g++ to force new operator to return
NULL instead of std::bad_alloc ?
Thank you,
Peter