From 5c8f26bba50f8a62facb092e92dc0160c320fa7d Mon Sep 17 00:00:00 2001 From: Roger Wang Date: Thu, 17 Mar 2016 14:14:37 +0800 Subject: [PATCH] Workaround of realloc in node_buffer Fix nwjs/nw.js#4357 --- src/node_buffer.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 0c936ec498d..2a6d43f6bc1 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -229,12 +229,18 @@ MaybeLocal 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(realloc(data, actual)); CHECK_NE(data, nullptr); } +#endif } Local buf;