delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/17/02:32:45

From: "Anthony.Appleyard" <MCLSSAA2 AT fs2 DOT mt DOT umist DOT ac DOT uk>
Organization: Materials Science Centre
To: djgpp AT delorie DOT com
Date: Tue, 17 Feb 1998 07:30:49 GMT
Subject: Re: new operator
Reply-to: Anthony DOT Appleyard AT umist DOT ac DOT uk
Message-ID: <11F1E9A1D17@fs2.mt.umist.ac.uk>

  mwallace AT wiltel DOT com (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.? Mike

  It returns 0, plainly, simply, thankfully.
  In my experiences with writing Windows applications, Borland C++ `new'
running out of memory throws an exception, which (on top of the near/far/huge
pointer type complication and a muddle of various sorts of `new' and `delete'
with and without round and square brackets after), caused a complication of
`throw' and `catch' and `try' which played pig-in-the-middle with half of a
day of my time before I rejected it and went back to malloc().

#define FM(type,n) (type  far*) farmalloc((long)sizeof(type)*(n))
#define HM(type,n) (type huge*) farmalloc((long)sizeof(type)*(n))

  Or, as anyone will know who have read Herriot's vet books, "it allus ends up
wi' malloc() at t' finish."

  A few useful abbreviating #defines which I often use:-
#define pk __attribute__((packed))
#define reg register
#define uns unsigned
#define OUCH MB_ICONEXCLAMATION

  P.S.1: Is there an email group like djgpp but about programming in C/C++ for
Windows?
  P.S.2: What is the progress on djgpp for Windows?

- Raw text -


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