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:
parent
8be4332765
commit
efe23b7595
4 changed files with 57 additions and 2 deletions
|
@ -21,6 +21,12 @@ namespace node {
|
|||
__declspec(dllexport) int open_osfhandle(intptr_t osfhandle, int flags);
|
||||
__declspec(dllexport) int close(int fd);
|
||||
|
||||
// Memory allocation functions from Node's module, used by ArrayBuffer allocator
|
||||
// to make sure memories are allocated and freed with the same allocator.
|
||||
__declspec(dllexport) void* ArrayBufferCalloc(size_t length);
|
||||
__declspec(dllexport) void* ArrayBufferMalloc(size_t length);
|
||||
__declspec(dllexport) void ArrayBufferFree(void* data, size_t length);
|
||||
|
||||
// A trick to force referencing symbols.
|
||||
__declspec(dllexport) void ReferenceSymbols();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue