On Wednesday 05 March 2003 10:31 am, Linus Torvalds wrote:
> Also note that if you don't allow exceptions (which I would _strongly_ 
> encourage), you can't really use "new" - unless you think it's ok to 
> SIGSEGV under low-mem circumstances. Which it might be, of course, in some 
> situations.

I may be wrong, but as I understood it C++ already provides a non-exception 
version of new ('nothrow' or similar) that will instead return 0 on failure 
for just this case.  This avoids combining malloc with placement newsall 
over.  The only disadvantage is having to check for 0 returns everwhere again 
rather than having a single exception catcher at some high-level entry point.

Also, 16.6 of the C++ FAQ Lite shows how you can easily replace new's error 
handler.  You wouldn't even have to worry about testing each new for 0 return 
everywhere--just handle it there and you're back to C++ clean-code goodness.


Nick


-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to