@@ -68,7 +68,7 @@ static void OnMessage(Local<Message> message, Local<Value> error) {
6868 }
6969}
7070
71- void * ArrayBufferAllocator ::Allocate (size_t size) {
71+ void * NodeArrayBufferAllocator ::Allocate (size_t size) {
7272 if (zero_fill_field_ || per_process::cli_options->zero_fill_all_buffers )
7373 return UncheckedCalloc (size);
7474 else
@@ -81,29 +81,29 @@ DebuggingArrayBufferAllocator::~DebuggingArrayBufferAllocator() {
8181
8282void * DebuggingArrayBufferAllocator::Allocate (size_t size) {
8383 Mutex::ScopedLock lock (mutex_);
84- void * data = ArrayBufferAllocator ::Allocate (size);
84+ void * data = NodeArrayBufferAllocator ::Allocate (size);
8585 RegisterPointerInternal (data, size);
8686 return data;
8787}
8888
8989void * DebuggingArrayBufferAllocator::AllocateUninitialized (size_t size) {
9090 Mutex::ScopedLock lock (mutex_);
91- void * data = ArrayBufferAllocator ::AllocateUninitialized (size);
91+ void * data = NodeArrayBufferAllocator ::AllocateUninitialized (size);
9292 RegisterPointerInternal (data, size);
9393 return data;
9494}
9595
9696void DebuggingArrayBufferAllocator::Free (void * data, size_t size) {
9797 Mutex::ScopedLock lock (mutex_);
9898 UnregisterPointerInternal (data, size);
99- ArrayBufferAllocator ::Free (data, size);
99+ NodeArrayBufferAllocator ::Free (data, size);
100100}
101101
102102void * DebuggingArrayBufferAllocator::Reallocate (void * data,
103103 size_t old_size,
104104 size_t size) {
105105 Mutex::ScopedLock lock (mutex_);
106- void * ret = ArrayBufferAllocator ::Reallocate (data, old_size, size);
106+ void * ret = NodeArrayBufferAllocator ::Reallocate (data, old_size, size);
107107 if (ret == nullptr ) {
108108 if (size == 0 ) // i.e. equivalent to free().
109109 UnregisterPointerInternal (data, old_size);
@@ -146,11 +146,15 @@ void DebuggingArrayBufferAllocator::RegisterPointerInternal(void* data,
146146 allocations_[data] = size;
147147}
148148
149- ArrayBufferAllocator* CreateArrayBufferAllocator ( ) {
150- if (per_process::cli_options->debug_arraybuffer_allocations )
151- return new DebuggingArrayBufferAllocator ();
149+ std::unique_ptr< ArrayBufferAllocator> ArrayBufferAllocator::Create ( bool debug ) {
150+ if (debug || per_process::cli_options->debug_arraybuffer_allocations )
151+ return std::make_unique< DebuggingArrayBufferAllocator> ();
152152 else
153- return new ArrayBufferAllocator ();
153+ return std::make_unique<NodeArrayBufferAllocator>();
154+ }
155+
156+ ArrayBufferAllocator* CreateArrayBufferAllocator () {
157+ return ArrayBufferAllocator::Create ().release ();
154158}
155159
156160void FreeArrayBufferAllocator (ArrayBufferAllocator* allocator) {
0 commit comments