Skip to content

Commit 6542755

Browse files
committed
Workaround of realloc in node_buffer
Fix nwjs/nw.js#4357
1 parent 1be49af commit 6542755

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/node_buffer.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,18 @@ MaybeLocal<Object> New(Isolate* isolate,
243243
CHECK(actual <= length);
244244

245245
if (actual == 0) {
246-
free(data);
246+
isolate->array_buffer_allocator()->Free(data, length);
247247
data = nullptr;
248-
} else if (actual < length) {
248+
}
249+
#if 0 //FIXME #4357: costs some extra bytes here. It shouldn't be
250+
//significant because of the length calculation in
251+
//StringBytes::Size()
252+
//v8 buffer allocator doesn't support reallocate
253+
else if (actual < length) {
249254
data = static_cast<char*>(realloc(data, actual));
250255
CHECK_NE(data, nullptr);
251256
}
257+
#endif
252258
}
253259

254260
Local<Object> buf;

0 commit comments

Comments
 (0)