mirror of
https://github.com/phpv8/v8js.git
synced 2025-03-11 22:18:44 +00:00
Provide ArrayBufferAllocator for v8 4.4.44 (and later)
This commit is contained in:
parent
81018372e4
commit
493e448bae
@ -65,6 +65,17 @@ struct v8js_jsext {
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
#if PHP_V8_API_VERSION >= 4004044
|
||||
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
||||
public:
|
||||
virtual void* Allocate(size_t length) {
|
||||
void* data = AllocateUninitialized(length);
|
||||
return data == NULL ? data : memset(data, 0, length);
|
||||
}
|
||||
virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
|
||||
virtual void Free(void* data, size_t) { free(data); }
|
||||
};
|
||||
#endif
|
||||
|
||||
static void v8js_free_storage(void *object TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
@ -303,7 +314,16 @@ static PHP_METHOD(V8Js, __construct)
|
||||
c->report_uncaught = report_uncaught;
|
||||
c->pending_exception = NULL;
|
||||
c->in_execution = 0;
|
||||
|
||||
#if PHP_V8_API_VERSION >= 4004044
|
||||
static ArrayBufferAllocator array_buffer_allocator;
|
||||
static v8::Isolate::CreateParams create_params;
|
||||
create_params.array_buffer_allocator = &array_buffer_allocator;
|
||||
c->isolate = v8::Isolate::New(create_params);
|
||||
#else
|
||||
c->isolate = v8::Isolate::New();
|
||||
#endif
|
||||
|
||||
c->isolate->SetData(0, c);
|
||||
|
||||
c->time_limit = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user