delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/29/02:15:38

Date: Mon, 29 Jul 1996 09:11:33 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Conrad Wei-Li Song <conradsong AT mail DOT utexas DOT edu>
Cc: djgpp AT delorie DOT com
Subject: Re: Malloc and realloc pains...
In-Reply-To: <199607290226.VAA01065@smtp.utexas.edu>
Message-Id: <Pine.SUN.3.91.960729090655.25853L-100000@is>
Mime-Version: 1.0

On Sun, 28 Jul 1996, Conrad Wei-Li Song wrote:

> Borland returns a NULL pointer on a malloc( (size_t)(0) );

The ANSI C Standard specifies that the behavior in this case is 
implementation-defined.  I guess if they say that, there are other 
libraries out there that behave that way.  Solution: don't call `malloc' 
with a zero argument, period.  (IMHO, whoever steps into a territory 
marked with ``implementation-defined'' or ``undefined'' signs is just 
looking for trouble.)

> Microsoft does not deallocate the passed memory block on a failed realloc.

That is what ANSI C specifies it should do.  If you see a `realloc' that 
behaves differently, then that other `realloc' is buggy.

- Raw text -


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