delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/08/12:08:38

From: Ian D Romanick <idr AT cs DOT pdx DOT edu>
Message-Id: <199701081652.IAA27192@xavier.cs.pdx.edu>
Subject: Re: free() question
To: djgpp AT delorie DOT com
Date: Wed, 8 Jan 1997 08:52:42 -0800 (PST)
In-Reply-To: <Pine.SUN.3.91.970108133837.494E-100000@is> from "Eli Zaretskii" at Jan 8, 97 01:38:58 pm
MIME-Version: 1.0

> On Wed, 8 Jan 1997, Dim Zegebart wrote:
> 
> > ptr1=(char*)malloc(sizeof(char)*1024);
> > if (ptr1!=NULL) ptr2=ptr1;
> > ....
> > 
> > //so my question. May i use 
> > free(ptr2);
> > //or i have to use
> > free(ptr1)
> 
> Both are OK.

I wouldn't put it quite that way.  *Either* is ok.  Doing both is quite
incorrect as it would free the same memory twice. :)

-- 
"By that marker, configuring Citadel is actually impossible because it involves
actually EDITING TEXT FILES.  Editing text files, in the eye of the general
public, requires a bachelors degree in computer science, even though you and
I did it when we were eleven." -- Steven Frank

- Raw text -


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