delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/08/10:18:42

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: NEW()
Date: Wed, 07 May 1997 20:03:18 -0400
Organization: Cornell University http://www.cornell.edu
Lines: 26
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <33711846.20EF@cornell.edu>
References: <199705071551 DOT RAA19436 AT ippc47 DOT cicrp DOT jussieu DOT fr>
Reply-To: asu1 AT cornell DOT edu
NNTP-Posting-Host: cu-dialup-0067.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Jimmy OBERTAN wrote:
> 
> Why the new call exits when there is not enough memory?

quoting from "The C++ Programming Language", 2nd ed. p.312

"If operator new() cannot find memory, it calls _new_handler(). If
(_new_handler() ) cannot supply enough memory, the handler cannot return
to operator new() without causing an infinite loop." 

hence, so long as you do not provide your own _new_handler(), the
default behavior of terminating the program is a sensible choice. if you
want different behavior, you need to write your own _new_handler() and
use set_new_handler to notify the particular class' operator new().
consult a C++ book for details.
-- 
   Sinan
 
*******************************************************************
 A. Sinan Unur                                WWWWWW
                                              |--O+O
 mailto:sinan DOT unur AT cornell DOT edu                C   ^ 
 http://www.people.cornell.edu/pages/asu1/     \  ~/ 

Unsolicited e-mail is _not_ welcome, and will be billed for.
*******************************************************************

- Raw text -


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