From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: free() Date: Sat, 27 Jun 1998 21:45:20 -0700 Organization: Alcyone Systems Lines: 30 Message-ID: <3595CA60.796C77B4@alcyone.com> References: <19980623 DOT 131350 DOT 7759 DOT 0 DOT zixyer AT juno DOT com> NNTP-Posting-Host: kamali.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Zixyer S Qwerty wrote: > How does free() know how much memory to return to the heap? Because you allocated it through malloc. > Does it have > to be the originally malloc()ed pointer or can it be a different > pointer > to the memory that was allocated? As long as the pointer is to the same address, it's the same pointer. > I'm writing a linked list and > keeping > pointers to each element around kinda defeats the purpose... thanks > in > advance for any help You certainly need to keep them around while you're still using them. Once you don't need to use memory anymore you should free it as soon as you're done with it. -- Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com Alcyone Systems / http://www.alcyone.com/max/ San Jose, California, United States / icbm:+37.20.07/-121.53.38 \ Regret it? nope. / Said it? yep. / Ice Cube