This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Can new operator return NULL ?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]