delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/09/08:31:00

Date: Thu, 9 Jan 1997 16:05:34 +0300 (MSK)
From: "Alexander V. Lukyanov" <lav AT video DOT yars DOT free DOT net>
Message-Id: <199701091305.QAA16082@video.yars.free.net>
To: res AT marstu DOT mari DOT su, zager AT post DOT comstar DOT ru
Cc: djgpp AT delorie DOT com
Subject: Re: Another aspect of free() ?

> If argument for FREE eq NULL you get the problem. :-(

It is so on some old or broken implementations. ANSI C standard
states that free(NULL) does nothing, and djgpp follows it.

> Instead XFREE correctly process NULL value. The problem
> is what you need xmalloc (i think so) for allocating memory
> to be freeing by xfree. Am i right ?

No, xmalloc is just a wrapper for malloc which checks malloc
return value for NULL, and if it is prints a message and calls
abort(). So it returns a the same pointer as if it was plain
malloc, but it can't be NULL. Thus you can safely free it with
free().

- Raw text -


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