home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / watcher / part01 / clean_hist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-09-27  |  983 b   |  46 lines

  1. /*
  2.    clean_hist: free up all memory used by the history structure.  The
  3.    main purpose of this is to use the range checking of malloc to check
  4.    for pointer problems.  If you don't have source, this is of dubious
  5.    value.
  6.  
  7.    Kenneth Ingham
  8.  
  9.    Copyright (C) 1987 The University of New Mexico
  10. */
  11.  
  12. #include "defs.h"
  13.  
  14. clean_hist()
  15. {
  16.     extern struct old_cmd_st *chead;
  17.     struct old_cmd_st *bcp;
  18.     struct val_st *vp, *bvp;
  19.     struct key_st *kp, *bkp;
  20.  
  21.     while (chead != NULL) {
  22.         printf("freeing '%s'\n",chead->pipeline);
  23.         free(chead->pipeline);
  24.         kp = chead->keys;
  25.         while (kp != NULL) {
  26.             printf("\tfreeing '%s'\n",kp->key_value);
  27.             free(kp->key_value);
  28.             vp = kp->vals;
  29.             while (vp != NULL) {
  30.                 printf("\tfreeing '%s'\n",kp->vals->name);
  31.                 free(vp->name);
  32.                 bvp = vp;
  33.                 vp = vp->next;
  34.                 free(bvp);
  35.             }
  36.             bkp = kp;
  37.             kp = kp->next;
  38.             free(bkp);
  39.         }
  40.         bcp = chead;
  41.         chead = chead->next;
  42.         free(bcp);
  43.     }
  44.     printf("\nThe world is now free again!  Aren't you glad?\n");
  45. }
  46.