Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit 5618fdd

Browse files
committed
Use convenience array buffer allocator
V8 commit: v8/v8@356a85b
1 parent 0753966 commit 5618fdd

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

src/php_v8_isolate.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ static void php_v8_isolate_free(zend_object *object) {
161161

162162
zend_object_std_dtor(&php_v8_isolate->std);
163163

164-
if (php_v8_isolate->array_buffer_allocator) {
165-
delete php_v8_isolate->array_buffer_allocator;
166-
}
167-
168164
if (php_v8_isolate->create_params) {
165+
if (php_v8_isolate->create_params->array_buffer_allocator) {
166+
delete php_v8_isolate->create_params->array_buffer_allocator;
167+
}
168+
169169
delete php_v8_isolate->create_params;
170170
}
171171
}
@@ -182,10 +182,8 @@ static zend_object *php_v8_isolate_ctor(zend_class_entry *ce) {
182182
// TODO: inline? module init?
183183
php_v8_init();
184184

185-
php_v8_isolate->array_buffer_allocator = new ArrayBufferAllocator();
186185
php_v8_isolate->create_params = new v8::Isolate::CreateParams();
187-
188-
php_v8_isolate->create_params->array_buffer_allocator = php_v8_isolate->array_buffer_allocator;
186+
php_v8_isolate->create_params->array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator();
189187

190188
php_v8_isolate->weak_function_templates = new std::map<v8::Persistent<v8::FunctionTemplate> *, php_v8_callbacks_t *>();
191189
php_v8_isolate->weak_object_templates = new std::map<v8::Persistent<v8::ObjectTemplate> *, php_v8_callbacks_t *>();

src/php_v8_isolate.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,8 @@ extern php_v8_isolate_t * php_v8_isolate_fetch_object(zend_object *obj);
117117
} \
118118

119119

120-
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
121-
public:
122-
virtual void* Allocate(size_t length) {
123-
void* data = AllocateUninitialized(length);
124-
return data == NULL ? data : memset(data, 0, length);
125-
}
126-
virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
127-
virtual void Free(void* data, size_t) { free(data); }
128-
};
129-
130120
struct _php_v8_isolate_t {
131121
v8::Isolate *isolate;
132-
ArrayBufferAllocator *array_buffer_allocator;
133122
v8::Isolate::CreateParams *create_params;
134123

135124
std::map<v8::Persistent<v8::FunctionTemplate>*, php_v8_callbacks_t *> *weak_function_templates;

0 commit comments

Comments
 (0)