Implement the stream port write callback for the dynamic_buffer_stream adapter.
This callback appends bytes to the adapter-managed in-memory dynamic buffer. When needed, it grows the underlying buffer before copying the requested data.
This function is a private backend callback bound into the dynamic_buffer_stream vtable. It implements the public behavior exposed through stream_write() for stream instances created by the dynamic_buffer_stream adapter.
See:
backend != NULL, backend must designate a valid dynamic_buffer_stream_t.backend == NULLbuf == NULL && n > 0If the arguments are valid and the write can be completed:
n bytes from buf to the end of the internal dynamic buffer. Bytes are appended at offset dbuf->lendbuf->len is increased by ndbuf->read_pos is unchangeddbuf->cap may increase if buffer growth was requirednst != NULL, *st is set to STREAM_STATUS_OK0.st != NULL, *st is set to STREAM_STATUS_INVALID.If n > SIZE_MAX - dbuf->len:
0.st != NULL, *st is set to STREAM_STATUS_INVALID.backend != NULL, backend is left unchanged.If the required capacity exceeds the representable growth policy, i.e. the capacity-doubling loop cannot produce a strictly larger valid capacity:
0st != NULL, *st is set to STREAM_STATUS_OOMbackend is left unchanged.If dynamic_buffer_stream_buffer_reserve() fails:
0st != NULL, *st is set to the status returned by dynamic_buffer_stream_buffer_reserve()backend is left unchanged.backend is borrowedbuf is borroweddynamic_buffer_stream_buffer_reserve().STREAM_STATUS_OOM may be returned either because allocation failed during reserve or because the growth policy could not represent a sufficient next capacity.