From: "Paul Derbyshire" Newsgroups: comp.os.msdos.djgpp References: <35594e81 DOT 4169631 AT 192 DOT 168 DOT 1 DOT 250> <8uh61.2667$z15 DOT 2572850 AT news21 DOT bellglobal DOT com> <35599b32 DOT 1408551 AT 192 DOT 168 DOT 1 DOT 250> Subject: Re: What does new do when memory is exhausted? Lines: 49 Organization: The Chaos Zone MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-ID: Date: Wed, 13 May 1998 15:19:09 GMT NNTP-Posting-Host: 206.172.228.122 NNTP-Posting-Date: Wed, 13 May 1998 11:19:09 EDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk >Is it possible to set this up to be the default behavior my modifying >some startup file or other? So you don't have to keep doing it in >every program? Yes and no... Include this .cc file in a project. // foo.cc // Fixes the new handler "bug". #include void __my_new_handler (void) { throw bad_alloc(); } class __dummy_class { __dummy_class (void) { set_new_handler(__may_new_handler); } }; __dummy_class __dummy_object; // This will construct at startup, and the // constructor will set the new handler. In another module, such as the one with main, #include this: // foo.h extern __dummy_class __dummy_object; // Force linker to link the foo.o. -- .*. "Clouds are not spheres, mountains are not cones, coastlines are not -() < circles, and bark is not smooth, nor does lightning travel in a `*' straight line." ------------------------------------------------- -- B. Mandelbrot |http://www3.sympatico.ca/bob.beland/indexn2f.html _____________________ ____|________ Paul Derbyshire pderbysh AT usa DOT net Programmer & Humanist|ICQ: 10423848| David Vrabel wrote in message <35599b32 DOT 1408551 AT 192 DOT 168 DOT 1 DOT 250>... > >David. > >David Vrabel d DOT vrabel AT n-shropshire DOT ac DOT uk >A poor student (aren't they all) at: >North Shropshire College >Oswestry, Shropshire, UK