delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/16/22:32:13

From: "John M. Aldrich" <fighteer AT cs DOT com>
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
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 <iostream.h>

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 <fighteer AT cs DOT com>  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------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019