Use asprintf rather than malloc+snprintf, free string when finished