Yang Lee wrote:
Hi,
I have a single link list. at the end of the program or in a
loop i want to destroy this link list.
so is it enough to free the pointer to this link list
or do i have to traverse whole link list until last node where next
field is null and free each node.
please suggest.
Lee...
If each list element was allocated using malloc() or calloc(),
then each element will need to be individually free()'d.
If storage for the entire list was allocated with a single
malloc() or calloc() call, then you'll need to use just one
free() call.
If the storage for the list wasn't allocated using malloc() or
calloc(), then you'd best not free() it.
--
Morris Dovey
West Des Moines, Iowa USA
C links at
http://www.iedu.com/c
Read my lips: The apple doesn't fall far from the tree.