> I have seen that in sipxtapi, sometimes we check for new failure with an
> if, sometimes we don't.
> 
> Standard behaviour is that if it runs out of memory, it throws
> std::bad_alloc. This holds for visual studio and gcc 2.95
> (http://www.gnu.org/software/gcc/gcc-2.95/c++features.html - * operator
> new now throws bad_alloc where appropriate.), but for WinCE, it returns 0.
>
> Checking with an if after each allocation and using delete can produce
> very complicated code.

In older versions of the Microsoft C++ libraries, new would also return 0
when
out of memory (instead of throwing std::bad_alloc like newer versions do).
However, there is a _set_new_handler() function that allows you to register
a function to be invoked whenever allocation fails.

I believe WinCE also supports _set_new_handler(), so this might be a much
cleaner
Solution.

Stephen C. Steel

_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/

Reply via email to