[Insight-developers] VC++ new and bad_alloc exception

Luis Ibanez luis . ibanez at kitware . com
Mon, 03 Jun 2002 09:37:28 -0400


Jim,

The idea is to just throw the bad_alloc exception when
the allocation fails.

I agree in that there is little opportunity for recovery,
but the application should at least have the chance to
catch the bad_alloc exception and act accordingly.
(e.g. report the error and close what it can).

Other options are:

1) test allocation against null (as in old-style C/C++)
    just to be safe in VC++.

    if( (myvar = new BigArray[ N ])  == NULL )....


2) not test at all and hope for the best.



I'll rather give it a try at the VC++ hack,
(but probably by WA5...)


   Luis


==================================================

Miller, James V (Research) wrote:
> Luis,
> 
> What do you plan to do if an alloc fails?
> 
> There is very little opportunity to recover.
> 
> Jim
> 
>