I'd start by fixing this so that it doesn't run off the end of the list and crash if the item is not found.
Next you'll need to actually call 'free' on something.