Consider the official documentation for libuv (section miscellaneous utilities).
This is the declaration of
uv_buf_init
uv_buf_t uv_buf_init(char* base, unsigned int len)
Constructor for uv_buf_t.
Due to platform differences the user cannot rely on the ordering of the base and len members of the uv_buf_t struct. The user is responsible for freeing base after the uv_buf_t is done. Return struct passed by value.
base
uv_buf_init
uv_buf_t
base
char *
len
size_t
uv_try_write
*_write
Data are not copied over to the uv_buf_t
, uv_buf_t.base
refers to the same array of characters you used to create it.
Because of that, you have no performance penalties, but also you cannot drop the data immediately after the call to uv_buf_init
.
Instead, you can free them once you have used the buffer, that is (as an example) when you have submitted it to uv_writeor
uv_try_write`.