Use Node's memory allocator for ArrayBuffer

For Buffers created in Node, they are usually allocated in Node and
freed by Chromium's allocator, which will cause crashes when Node and
Chromium are using different allocators.

This commit makes Chromium use Node' allocator for ArrayBuffers.
This commit is contained in:
Cheng Zhao 2017-05-09 14:12:39 +09:00
parent 8be4332765
commit efe23b7595
4 changed files with 57 additions and 2 deletions

View file

@ -25,6 +25,7 @@
#include "third_party/icu/source/i18n/unicode/uregex.h"
#include "third_party/icu/source/i18n/unicode/uspoof.h"
#include "third_party/icu/source/i18n/unicode/usearch.h"
#include "util-inl.h"
#include "v8-profiler.h"
#include "v8-inspector.h"
@ -38,6 +39,18 @@ int close(int fd) {
return _close(fd);
}
void* ArrayBufferCalloc(size_t length) {
return UncheckedCalloc(length);
}
void* ArrayBufferMalloc(size_t length) {
return UncheckedMalloc(length);
}
void ArrayBufferFree(void* data, size_t length) {
return ::free(data);
}
void ReferenceSymbols() {
// Following symbols are used by electron.exe but got stripped by compiler,
// by using the symbols we can force compiler to keep the objects in node.dll,