Skip to content

Commit

Permalink
Workaround of realloc in node_buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwang committed Mar 18, 2016
1 parent 6a88b1a commit 5c8f26b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,18 @@ MaybeLocal<Object> New(Isolate* isolate,
CHECK(actual <= length);

if (actual == 0) {
free(data);
isolate->array_buffer_allocator()->Free(data, length);
data = nullptr;
} else if (actual < length) {
}
#if 0 //FIXME #4357: costs some extra bytes here. It shouldn't be
//significant because of the length calculation in
//StringBytes::Size()
//v8 buffer allocator doesn't support reallocate
else if (actual < length) {
data = static_cast<char*>(realloc(data, actual));
CHECK_NE(data, nullptr);
}
#endif
}

Local<Object> buf;
Expand Down

0 comments on commit 5c8f26b

Please sign in to comment.