Or, if you know your struct string well enough, you can overallocate enough to write the string into the buffer itself.