Merge pull request #3341 from murgatroid99/node_memory_leak_0_11

Fixed a couple of memory leaks in Node library
pull/3365/head^2
Tim Emiola 9 years ago
commit 1965810ede
  1. 2
      src/node/ext/byte_buffer.cc
  2. 5
      src/node/ext/call.cc
  3. 2
      src/node/ext/call.h

@ -77,7 +77,7 @@ Handle<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
memcpy(result + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next)); memcpy(result + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next));
offset += GPR_SLICE_LENGTH(next); offset += GPR_SLICE_LENGTH(next);
} }
return NanEscapeScope(MakeFastBuffer(NanNewBufferHandle(result, length))); return NanEscapeScope(MakeFastBuffer(NanBufferUse(result, length)));
} }
Handle<Value> MakeFastBuffer(Handle<Value> slowBuffer) { Handle<Value> MakeFastBuffer(Handle<Value> slowBuffer) {

@ -172,6 +172,9 @@ Handle<Value> Op::GetOpType() const {
return NanEscapeScope(NanNew<String>(GetTypeString())); return NanEscapeScope(NanNew<String>(GetTypeString()));
} }
Op::~Op() {
}
class SendMetadataOp : public Op { class SendMetadataOp : public Op {
public: public:
Handle<Value> GetNodeValue() const { Handle<Value> GetNodeValue() const {
@ -325,7 +328,7 @@ class ReadMessageOp : public Op {
} }
~ReadMessageOp() { ~ReadMessageOp() {
if (recv_message != NULL) { if (recv_message != NULL) {
gpr_free(recv_message); grpc_byte_buffer_destroy(recv_message);
} }
} }
Handle<Value> GetNodeValue() const { Handle<Value> GetNodeValue() const {

@ -88,6 +88,7 @@ struct Resources {
class Op { class Op {
public: public:
virtual ~Op();
virtual v8::Handle<v8::Value> GetNodeValue() const = 0; virtual v8::Handle<v8::Value> GetNodeValue() const = 0;
virtual bool ParseOp(v8::Handle<v8::Value> value, grpc_op *out, virtual bool ParseOp(v8::Handle<v8::Value> value, grpc_op *out,
shared_ptr<Resources> resources) = 0; shared_ptr<Resources> resources) = 0;
@ -98,7 +99,6 @@ class Op {
}; };
typedef std::vector<unique_ptr<Op>> OpVec; typedef std::vector<unique_ptr<Op>> OpVec;
struct tag { struct tag {
tag(NanCallback *callback, OpVec *ops, tag(NanCallback *callback, OpVec *ops,
shared_ptr<Resources> resources); shared_ptr<Resources> resources);

Loading…
Cancel
Save