@@ -71,6 +71,7 @@ struct v8js_jsext {
7171};
7272/* }}} */
7373
74+ #ifdef USE_INTERNAL_ALLOCATOR
7475class ArrayBufferAllocator : public v8 ::ArrayBuffer::Allocator {
7576public:
7677 virtual void * Allocate (size_t length) {
@@ -80,6 +81,7 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
8081 virtual void * AllocateUninitialized (size_t length) { return malloc (length); }
8182 virtual void Free (void * data, size_t ) { free (data); }
8283};
84+ #endif /* * USE_INTERNAL_ALLOCATOR */
8385
8486
8587static void v8js_free_storage (zend_object *object) /* {{{ */
@@ -201,6 +203,10 @@ static void v8js_free_storage(zend_object *object) /* {{{ */
201203 c->modules_base .~vector ();
202204
203205 zval_ptr_dtor (&c->zval_snapshot_blob );
206+
207+ #ifndef USE_INTERNAL_ALLOCATOR
208+ delete c->create_params .array_buffer_allocator ;
209+ #endif
204210}
205211/* }}} */
206212
@@ -353,8 +359,12 @@ static PHP_METHOD(V8Js, __construct)
353359
354360 new (&c->create_params ) v8::Isolate::CreateParams ();
355361
362+ #ifdef USE_INTERNAL_ALLOCATOR
356363 static ArrayBufferAllocator array_buffer_allocator;
357364 c->create_params .array_buffer_allocator = &array_buffer_allocator;
365+ #else
366+ c->create_params .array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator ();
367+ #endif
358368
359369 new (&c->snapshot_blob ) v8::StartupData ();
360370 if (snapshot_blob) {
0 commit comments