Re: Linked list question

From: Steve (quickey@cyberverse.com)
Date: 04/19/96


On Fri, 19 Apr 1996, Hades wrote:

> Say I do this:
> struct blah_data *blahstuff;
> 
> And blahstuff gets some info in it, and blahstuff->list becomes a linked
> list. If I free(blahstuff) what happens to the list? Will it free the entire
> list or does it just leave it there in memory?
> 
> could I do this?
> 
> newblahstuff->list = blahstuff->list;
> free(blahstuff);
as long as newblahstuff != blahstuff it should be ok, because if 
newblahstuff points to the same memory as blahstuff, and you free what is 
at blahstuff, newblahstuff points at freed memory (this is bad)

> And would newblahstuff have the old linked list from blahstuff even though
> blahstuff has been freed?
only the data in blahstuff is free'd, (but the data pointed to by a 
pointer in blahstuff is still there) hope this didn't confuse you more :)

Steve
quickey@cyberverse.com



This archive was generated by hypermail 2b30 : 12/18/00 PST