Mail Archives: djgpp/1998/06/28/01:48:02
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
- Raw text -