www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/16/17:00:55

From: "DeHackEd" <Not DOT given AT out>
References: <01bd804b$1a8b9620$433461cb AT matthew-barker>
Subject: Re: Int handlers in DJGPP
Date: Sat, 16 May 1998 16:57:14 -0400
Lines: 38
Message-ID: <#IlQg0Qg9GA.268@uppubnews03>
Newsgroups: comp.os.msdos.djgpp
NNTP-Posting-Host: d8-bn46-blvl-pda.attcanada.net [142.194.137.200]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>2) DJGPP doesn't seem to provide any set_new_handler() function, is there
>an equivalent function for this or do I have to do this myself??


This is quite interesting. A lot of people say there is none, but I know there
is.

Try this code. Just try it, and remember to use GXX or GPP or G++ or whatever it
is. Screwed me up during the 2.8.1 upgrade... :)

#include <iostream.h>
#include <stdlib.h>
#include <new.h>

void no_memory(void)
 {
   cerr << "There is no more memory to allocate...\n";
   exit(0);
 }

void main(void)
 {
   char *ptr;

   set_new_handler(no_memory);

   do {
     ptr = new char[10000];

     if (ptr)
       cout << "Just allocated 10,000 bytes\n";
   } while (ptr);
 }

// Look in the DJGPP\LANG\CXX\STD\NEW.H header file...



- Raw text -


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