www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/26/19:52:47

From: Eric Rudd <rudd AT cyberoptics DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Freeing null
Date: 26 Feb 1997 16:26:07 GMT
Organization: CyberOptics Corp
Lines: 18
Message-ID: <5f1o6v$ptr@hagar.cyberoptics.com>
References: <5etnpb$42p AT freenet-news DOT carleton DOT ca> <malyonE66p7u DOT Ju0 AT netcom DOT com> <3314684D DOT 51C1 AT blackmagic DOT tait DOT co DOT nz>
NNTP-Posting-Host: rudd.cyberoptics.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz> wrote:
>Roland Acton wrote:
>> 
>> Paul Derbyshire (ao950 AT FreeNet DOT Carleton DOT CA) wrote:
>> 
>> : What are the effects of free(ptr) if ptr happens to be null?

>Returns the allocated memory to the heap (*note malloc::.).  If the PTR
>is `NULL', it does nothing.

As a matter of fact, this behavior is required by the ANSI/ISO 
standard.  In sub-clause 7.10.3.2, it is stated that "If _ptr_ is 
a null pointer, no action occurs."  Thus, free(NULL) is not only 
accepted by gcc; it can be used in portable programs.

-Eric Rudd
rudd AT cyberoptics DOT com

- Raw text -


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