Add support for freeing complex objects in a list.

Changes the freelist function to take a function parameter that 
knows how to deallocate complex objects in the list, since using 
`free` on data types that require a special deallocation function 
is uncertain.