mirror of
https://github.com/phpv8/v8js.git
synced 2024-11-09 16:28:41 +00:00
Fixed script destructor and free resource struct when done.
This commit is contained in:
parent
de8b0666a6
commit
200c16c30e
@ -292,7 +292,7 @@ typedef struct _php_v8js_script {
|
||||
v8::Persistent<v8::Script, v8::CopyablePersistentTraits<v8::Script>> *script;
|
||||
} php_v8js_script;
|
||||
|
||||
static void php_v8js_script_free(php_v8js_script *res);
|
||||
static void php_v8js_script_free(php_v8js_script *res, bool dispose_persistent);
|
||||
|
||||
#endif /* PHP_V8JS_MACROS_H */
|
||||
|
||||
|
16
v8js.cc
16
v8js.cc
@ -1316,7 +1316,7 @@ static PHP_METHOD(V8Js, executeString)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
php_v8js_execute_script(getThis(), res, flags, time_limit, memory_limit, &return_value);
|
||||
php_v8js_script_free(res);
|
||||
php_v8js_script_free(res, true);
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
@ -1521,19 +1521,25 @@ static void php_v8js_persistent_zval_dtor(zval **p) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void php_v8js_script_free(php_v8js_script *res)
|
||||
static void php_v8js_script_free(php_v8js_script *res, bool dispose_persistent)
|
||||
{
|
||||
if (res->name) {
|
||||
efree(res->name);
|
||||
res->name = NULL;
|
||||
}
|
||||
if (dispose_persistent) {
|
||||
res->script->~Persistent(); // does Reset()
|
||||
res->script = NULL;
|
||||
}
|
||||
res->script->Reset();
|
||||
res->script->~Persistent();
|
||||
}
|
||||
|
||||
static void php_v8js_script_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
php_v8js_script *res = (php_v8js_script *)rsrc->ptr;
|
||||
if (res) php_v8js_script_free(res);
|
||||
if (res) {
|
||||
php_v8js_script_free(res, false);
|
||||
efree(res);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user