Add dealloc function to LinkedList.