freeing mallocd memory