Copies every chunk, then allocates the exact result size once and copies each chunk into it. Runtime is O(n); peak memory is roughly input + output.
Optional
Copies every chunk, then allocates the exact result size once and copies each chunk into it. Runtime is O(n); peak memory is roughly input + output.