free does nothing if parameter equals NULL
snprintf already calculated the length