Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!mcnc!borg!weiss!warner From: warner@weiss.cs.unc.edu (Byron Warner) Newsgroups: comp.lang.c Subject: Deleting linked lists. Keywords: C, C++. Message-ID: <2636@borg.cs.unc.edu> Date: 27 Mar 91 00:43:26 GMT Sender: news@cs.unc.edu Distribution: na Lines: 19 I was wondering, is it safe to unallocate a singly linked list like this: struct list *head; /* top of list */ struct list *ptr = head; while (ptr){ 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. -- ---- Byron F. Warner warner@cs.unc.edu University of North Carolina - Chapel Hill Computer Sci Department "The opinions expressed here should be yours."