Allocate the buffer first and copy the tag data directly into it?  Saves an allocation.