Pass delete[] explicitely to Nan::NewBuffer.

Use the Nan::NewBuffer version that accepts an explicit callback
deallocating buffers. This way we'll be resilient to different nan/node
versions.

Fixes grpc/grpc#4867
pull/5185/head
Patryk Lesiewicz 9 years ago
parent fff1cb7f61
commit 777777efa4
  1. 6
      src/node/ext/byte_buffer.cc

@ -63,6 +63,10 @@ grpc_byte_buffer *BufferToByteBuffer(Local<Value> buffer) {
return byte_buffer;
}
namespace {
void delete_buffer(char *data, void *hint) { delete[] data; }
}
Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
Nan::EscapableHandleScope scope;
if (buffer == NULL) {
@ -80,7 +84,7 @@ Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
gpr_slice_unref(next);
}
return scope.Escape(MakeFastBuffer(
Nan::NewBuffer(result, length).ToLocalChecked()));
Nan::NewBuffer(result, length, delete_buffer, NULL).ToLocalChecked()));
}
Local<Value> MakeFastBuffer(Local<Value> slowBuffer) {

Loading…
Cancel
Save