[haiku-development] possible bad usage of "new" in haiku

  • From: romain.haiku@xxxxxxxxxxx
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 2 Nov 2008 21:36:42 +0100 (CET)

Hello everybody,

I felt on this page last week:
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=170

And I wonder if we do not missuse the "new" operator in haiku. For example
in libbe.so, exceptions are not used (and afaik most/all of haiku code do
not use them also). According to the previous link, testing for new
returning null is nonsense on new compilers. This may not be an issue for
the old gcc 2.95, but probably for 4.x.

I discovered the nothrow notion with this link so I may miss something.
Maybe we should make all haiku classes inherit from a common class that
would just overload new with something like that:

void* operator new( std::size_t size ) {
  return ::operator new( size, std::nothrow );
}

Such an error has few chances to occur on a pc since this would require
the swap to be full, but on embedded systems this is something that will
occur. It would be sad that the application server dies because of this.

Romain.


Other related posts: