From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: new operator Date: Mon, 16 Feb 1998 22:00:09 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 36 Message-ID: <34E8FD39.470E@cs.com> References: <6cacaa$c5n1 AT walter DOT wcom DOT com> NNTP-Posting-Host: ppp242.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Michael Wallace x3738 wrote: > > In DJGPP, does the new operator throw an exception if it cannot allocate > the requested memory? Or does it just return a NULL value.? Well, I suppose you could test it yourself... it's not exactly a major bit of programming. However, I decided to try it out of personal curiosity. Here are my results: #include int main( void ) { char *c; c = new char[1024*1024*1024]; delete[] c; return 0; } [WIN] D:\TEMP>new Virtual memory exceeded in `new' According to my C++ textbook, you can #include a special header file that defines a version of new that supports exceptions. -- John M. Aldrich, aka Fighteer I UIN# 7406319 -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS d- s+:- a-->? C++>$ U@>++$ p>+ L>++ E>++ W++ N++ o+>++ K? w(---) O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+(++) tv+() b+++ DI++ D++ G>++ e(*)>++++ h!() !r !y+() ------END GEEK CODE BLOCK------