Frees the memory pointed to by mem.
mem
If mem is null it simply returns, so there is no need to check mem against null before calling this function.
the memory to free