Implement #22, support for caller-provided output buffers