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

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 03 Nov 2008 11:41:22 +0100

Axel Dörfler wrote:
> romain.haiku@xxxxxxxxxxx wrote:
> > 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:
> 
> As inherited from the Be API, our API is indeed not supposed to throw any 
> exceptions. Therefore, all API implementations are bound to use new 
> (std::nothrow) all the time.
> If you detect any usage of "new" without std::nothrow, please open a bug 
> report for this or supply patches that fixes those instances.

If you spot usage of new without std::nothrow in applications and preflets, 
I would not report all those, just within the kits. Otherwise we would be 
overwelmed with the reports. One more question though: What about "new 
BMessage"? AFAIU, BMessage has a custom allocator? Can nothrow be ommited 
there?

Best regards,
-Stephan

Other related posts: