Deleting linked lists.

Doug Gwyn gwyn at smoke.brl.mil
Thu Mar 28 07:31:12 AEST 1991


In article <2636 at borg.cs.unc.edu> warner at weiss.cs.unc.edu (Byron Warner) writes:
>	free(ptr);
>	ptr = ptr->next;
>I am not sure if I can assume that
>the value of ptr will not be corrupted
>after it is freed.

It's not ptr, but rather the region of storage to which ptr points,
that can be clobbered by the call to free().

Indeed I made this mistake once (in an early release of my dirent
implementation).  I knew better, I just forgot.



More information about the Comp.lang.c mailing list