home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / freelist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-06  |  758 b   |  39 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: freelist.c,v 1.4 1995/06/06 10:45:56 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    freelist.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    28 May 1984
  9.  * Last update:    28 May 1984
  10.  *
  11.  * Function:    This procedure releases all elements in a linked list which
  12.  *        were previously allocated using malloc, or calloc.  The
  13.  *        list is linked with the next-pointer in the first location
  14.  *        of each entry.  (The storage allocator knows how long the
  15.  *        entries actually were.)
  16.  */
  17.  
  18. #include <stdlib.h>
  19.  
  20. #include "freelist.h"
  21.  
  22. #define    ENTRY    struct _freelist
  23. ENTRY {
  24.     ENTRY    *next;
  25.     };
  26.  
  27. void    freelist (void *list)
  28. {
  29.     ENTRY    *first_ = (ENTRY *)list;
  30.     ENTRY    *next_;
  31.  
  32.     while (first_)
  33.     {
  34.         next_ = first_->next;
  35.         free (first_);
  36.         first_ = next_;
  37.     }
  38. }
  39.