[repacker] create repacker output buffer after final length is known. Don't rely on a buffer provided by the caller, as it may not be large enough.