Listing 18 Restores traditional "return-null" behavior

// exhaust2.cpp
#include <iostream.h>
#include <stdlib.h>
#include <new.h>
#include <assert.h>

main()
{
   set_new_handler(0);

   for (int i = 0; ; ++i)
   {
      double *dp = new double[100];
      if ((i+1)%10 == 0)
         cout << (i+1) <<" allocations" << endl;
      assert(dp);
   }
}

/* Output:
10 allocations
20 allocations
30 allocations
40 allocations
50 allocations
60 allocations
70 allocations
Assertion failed: dp, file exhaust3.cpp, line 15
Abnormal program termination
*/

// End of File