previous | index | next

Freeing Linked Structures

To free all the memory taken by linked structures, you must loop through them and for each individual struct you must:
  void freeList(list lst) {
      while ( lst != NULL ) {
          list save = lst;
          lst = lst->rest;
          delete save;
      }
  }

previous | index | next