joyent/libuv — Issue #301: Is comment for uv_write function valid?
Author: bsnote
Created: 2012-01-31 12:18:08+00:00
State: open

```c
/* The buffers to be written must remain valid until the callback is called.
* This is not required for the uv_buf_t array.
*/
int uv_write(uv_write_t* req, uv_stream_t* stream, uv_buf_t bufs[], int bufcnt,
uv_write_cb cb) {
...
/* Initialize the req */
uv__req_init((uv_req_t*) req);
req->cb = cb;
req->handle = stream;
req->error = 0;
req->type = UV_WRITE;
ngx_queue_init(&req->queue);

if (bufcnt <= UV_REQ_BUFSML_SIZE) {
req->bufs = req->bufsml;
}
else {
req->bufs = malloc(sizeof(uv_buf_t) * bufcnt);
}

memcpy(req->bufs, bufs, bufcnt * sizeof(uv_buf_t));
req->bufcnt = bufcnt;
...
}
```
I think that it should be specified in the comment that buffers can be freed immediately after `uv_write` function call.