When data arrives in socket libuv invokes uv_alloc_cb callback. Application is supposed to provide pointer to buffer (along with its length) so that libuv can read the data into it and invokes read_cb.
In uv_alloc_cb, We *can* allocate new buffer each time in uv_alloc_cb and delete it in read_cb. But we don't need to do that. Instead we can give pointer to static/global buffer. Since the callback occurs each time through same single thread (event loop) we can safely reuse same buffer there. HTH, Ashish On Tuesday, December 2, 2014 2:44:16 PM UTC+5:30, DJ wrote: > > I'm new to libuv. I am not clear on uv_buf_t buffers' lifecycle which are > allocated via uv_alloc_cb. Is it reasonable to believe that once libuv uses > the buffer to read data and invokes the associated uv_read_cb, I'm > essentially free to delete the buffer? Also - is it ok to reuse buffers or > is that not a recommended practice? > -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
