On Mon, Apr 22, 2013 at 8:12 PM, Liam <[email protected]> wrote: > A C++ module needs to use a Buffer received as an argument of a JS method in > a uv_queue_work procedure. I believe this means I need to > buf->Ref()/Unref(). To do so, I need to ObjectWrap::Unwrap<Buffer>(). > However node_buffer.h now declares: >> >> There should not be any ObjectWrap::Unwrap<Buffer>() calls. You should >> not be storing pointers to Buffer objects at all - as they are >> now considered internal structures. > > > The only alternative would be to new char[x] + memcpy() the Buffer, which > seems needless. > > It would be nice to have a way to simply extract the memory from a Buffer > (meaning the client calls delete[]).
Call node::Buffer::Data(buf_obj) and node::Buffer::Length(buf_obj) before you call uv_queue_work() and store the values in a struct that you pass to the work callback. Make sure that the buffer is not garbage collected until your done callback is invoked. The usual approach is to stuff buf_obj in a v8::Persistent<v8::Object> handle. Call Dispose() once you're done. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
