PRO freeLinkedList, head

;;-----------------------------------------------------------------------------
;; PURPOSE:
;;	Removes a linked list from the heap. For this to work, each item in the
;;	list must have an entry called "next" which is a pointer pointing to
;;	the next item in the list.
;;
;; CALLING SEQUENCE:
;;	freeLinkedList, head
;;
;; REQUIRED INPUTS:
;;	head - pointer to the head of the list
;;
;; OUTPUTS:
;;		
;;
;; OPTIONAL INPUT KEYWORDS:
;;
;; EXAMPLE:
;;      IDL> freeLinkedList, head
;;
;; PROCEDURES USED (i.e. called directly!):
;;
;; MODIFICATION HISTORY:
;;   	2004-09-27  M. Desnoyer - Created
;;
;;-----------------------------------------------------------------------------

;; Stop the recursion
IF NOT ptr_valid(head) THEN RETURN

freeLinkedList, (*head).next

ptr_free, head

END