Skip to content

Commit 404e0c2

Browse files
committed
Workaround of realloc in node_buffer
Fix nwjs/nw.js#4357
1 parent 13f460c commit 404e0c2

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
@@ -229,12 +229,18 @@ MaybeLocal<Object> New(Isolate* isolate,
229229
CHECK(actual <= length);
230230

231231
if (actual == 0) {
232-
free(data);
232+
isolate->array_buffer_allocator()->Free(data, length);
233233
data = nullptr;
234-
} else if (actual < length) {
234+
}
235+
#if 0 //FIXME #4357: costs some extra bytes here. It shouldn't be
236+
//significant because of the length calculation in
237+
//StringBytes::Size()
238+
//v8 buffer allocator doesn't support reallocate
239+
else if (actual < length) {
235240
data = static_cast<char*>(realloc(data, actual));
236241
CHECK_NE(data, nullptr);
237242
}
243+
#endif
238244
}
239245

240246
Local<Object> buf;

0 commit comments

Comments
 (0)