Free All Objects In A TList

When programming in Delphi, I often find myself creating objects and adding them to a TList.  To safely deallocate these objects I would need to loop throgh the list, destroying each object each time I cleared that list.  I found myself doing this so often I wrote the following function to take care of this for me:

Using FreeList

The FreeList function does not destroy the list itself, but will loop through the list destroying each object held within the list.  It will automatically skip any nil pointers held in the list.


List: A TList object containing references to the objects to be destroyed.

Return Value:

This procedure has no return value.