delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/12/18:01:27

From: "Lion" <ifestos AT the DOT forthnet DOT gr>
Newsgroups: comp.os.msdos.djgpp
Subject: operator new
Date: Wed, 13 May 1998 00:46:23 -0700
Organization: EMPA
Lines: 33
Message-ID: <6jafls$s3b$1@sharon.forthnet.gr>
NNTP-Posting-Host: ppp19.the.forthnet.gr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Why this piece of code exit with problem?
I think, new operator returns 0 if there is no memory available...

main ()
{
 int ii;
 for (;;) if (!(ii=new int) break;
}

And if i am wrong how can i install a new_handler like the following?

#include <new.h>

int memory_full=0;

void my_new_handler()
{
 memory_full=1;
}

main ()
{
 int ii;
 set_new_handler(my_new_handler);
 for (;;) if (!memory_full) ii=new int;
}

Thanks!
leonidas AT freemail DOT gr
ifestos AT the DOT forthnet DOT gr



- Raw text -


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