frees memory associated with previous malloc calls in problems 8 and 9