Removed useless zval_ptr_dtor()

This commit is contained in:
Dmitry Stogov 2018-05-29 17:58:06 +03:00
parent 44be0fa67b
commit d90c6f2443
24 changed files with 41 additions and 70 deletions

View File

@ -1341,7 +1341,7 @@ static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list a
CG(in_compilation) = 0;
}
if (call_user_function_ex(CG(function_table), NULL, &orig_user_error_handler, &retval, 5, params, 1, NULL) == SUCCESS) {
if (call_user_function(CG(function_table), NULL, &orig_user_error_handler, &retval, 5, params) == SUCCESS) {
if (Z_TYPE(retval) != IS_UNDEF) {
if (Z_TYPE(retval) == IS_FALSE) {
zend_error_cb(type, error_filename, error_lineno, format, args);
@ -1361,10 +1361,8 @@ static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list a
}
zval_ptr_dtor(&params[4]);
zval_ptr_dtor(&params[3]);
zval_ptr_dtor(&params[2]);
zval_ptr_dtor(&params[1]);
zval_ptr_dtor(&params[0]);
if (Z_TYPE(EG(user_error_handler)) == IS_UNDEF) {
ZVAL_COPY_VALUE(&EG(user_error_handler), &orig_user_error_handler);
@ -1529,7 +1527,7 @@ ZEND_API void zend_try_exception_handler() /* {{{ */
ZVAL_OBJ(&params[0], old_exception);
ZVAL_COPY_VALUE(&orig_user_exception_handler, &EG(user_exception_handler));
if (call_user_function_ex(CG(function_table), NULL, &orig_user_exception_handler, &retval2, 1, params, 1, NULL) == SUCCESS) {
if (call_user_function(CG(function_table), NULL, &orig_user_exception_handler, &retval2, 1, params) == SUCCESS) {
zval_ptr_dtor(&retval2);
if (EG(exception)) {
OBJ_RELEASE(EG(exception));

View File

@ -1740,7 +1740,6 @@ ZEND_API int add_property_long_ex(zval *arg, const char *key, size_t key_len, ze
ZVAL_LONG(&tmp, n);
ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
return SUCCESS;
}
@ -1754,7 +1753,6 @@ ZEND_API int add_property_bool_ex(zval *arg, const char *key, size_t key_len, ze
ZVAL_BOOL(&tmp, b);
ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
return SUCCESS;
}
@ -1768,7 +1766,6 @@ ZEND_API int add_property_null_ex(zval *arg, const char *key, size_t key_len) /*
ZVAL_NULL(&tmp);
ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
return SUCCESS;
}
@ -1796,7 +1793,6 @@ ZEND_API int add_property_double_ex(zval *arg, const char *key, size_t key_len,
ZVAL_DOUBLE(&tmp, d);
ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
return SUCCESS;
}

View File

@ -51,7 +51,7 @@ ZEND_METHOD(Closure, __invoke) /* {{{ */
zend_function *func = EX(func);
zval *arguments = ZEND_CALL_ARG(execute_data, 1);
if (call_user_function_ex(CG(function_table), NULL, getThis(), return_value, ZEND_NUM_ARGS(), arguments, 1, NULL) == FAILURE) {
if (call_user_function(CG(function_table), NULL, getThis(), return_value, ZEND_NUM_ARGS(), arguments) == FAILURE) {
RETVAL_FALSE;
}

View File

@ -2433,7 +2433,6 @@ try_again:
ZVAL_LONG(&op2, 1);
res = Z_OBJ_HANDLER_P(op1, do_operation)(ZEND_ADD, op1, op1, &op2);
zval_ptr_dtor(&op2);
return res;
}
@ -2501,7 +2500,6 @@ try_again:
ZVAL_LONG(&op2, 1);
res = Z_OBJ_HANDLER_P(op1, do_operation)(ZEND_SUB, op1, op1, &op2);
zval_ptr_dtor(&op2);
return res;
}

View File

@ -288,8 +288,8 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
} else if (wFlags & DISPATCH_METHOD) {
zend_try {
retval = &rv;
if (SUCCESS == call_user_function_ex(EG(function_table), &disp->object, name,
retval, pdp->cArgs, params, 1, NULL)) {
if (SUCCESS == call_user_function(EG(function_table), &disp->object, name,
retval, pdp->cArgs, params)) {
ret = S_OK;
trace("function called ok\n");

View File

@ -1553,10 +1553,6 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
}
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
zval_ptr_dtor(&argv[2]);
zval_ptr_dtor(&argv[3]);
zval_ptr_dtor(&argv[4]);
break;
}
}
@ -1619,7 +1615,6 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
zval_ptr_dtor(&argv[2]);
break;
}
}

View File

@ -462,7 +462,7 @@ static int php_json_encode_serializable_object(smart_str *buf, zval *val, int op
ZVAL_STRING(&fname, "jsonSerialize");
if (FAILURE == call_user_function_ex(EG(function_table), val, &fname, &retval, 0, NULL, 1, NULL) || Z_TYPE(retval) == IS_UNDEF) {
if (FAILURE == call_user_function(EG(function_table), val, &fname, &retval, 0, NULL) || Z_TYPE(retval) == IS_UNDEF) {
if (!EG(exception)) {
zend_throw_exception_ex(NULL, 0, "Failed calling %s::jsonSerialize()", ZSTR_VAL(ce->name));
}

View File

@ -1463,8 +1463,9 @@ void pcntl_signal_dispatch()
/* FIXME: this is probably broken when multiple signals are handled in this while loop (retval) */
call_user_function(EG(function_table), NULL, handle, &retval, 2, params);
zval_ptr_dtor(&retval);
zval_ptr_dtor(&params[0]);
#ifdef HAVE_STRUCT_SIGINFO_T
zval_ptr_dtor(&params[1]);
#endif
}
}

View File

@ -509,7 +509,6 @@ static void _readline_long_zval(zval *ret, long l)
static char **_readline_completion_cb(const char *text, int start, int end)
{
zval params[3];
int i;
char **matches = NULL;
_readline_string_zval(&params[0], text);
@ -531,9 +530,7 @@ static char **_readline_completion_cb(const char *text, int start, int end)
}
}
for (i = 0; i < 3; i++) {
zval_ptr_dtor(&params[i]);
}
zval_ptr_dtor(&params[0]);
zval_ptr_dtor(&_readline_array);
return matches;

View File

@ -1470,7 +1470,7 @@ ZEND_METHOD(reflection, export)
/* Invoke the __toString() method */
ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring") - 1);
result= call_user_function_ex(NULL, object, &fname, &retval, 0, NULL, 0, NULL);
result= call_user_function(NULL, object, &fname, &retval, 0, NULL);
zval_dtor(&fname);
if (result == FAILURE) {

View File

@ -2563,8 +2563,6 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
_bailout = 1;
} zend_end_try();
zval_ptr_dtor(&func);
zval_ptr_dtor(&params[4]);
zval_ptr_dtor(&params[3]);
zval_ptr_dtor(&params[2]);
zval_ptr_dtor(&params[1]);
zval_ptr_dtor(&params[0]);

View File

@ -1479,7 +1479,7 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam
if (!use_arg) {
intern->nApplyCount++;
call_user_function_ex(EG(function_table), NULL, &function_name, return_value, 1, params, 1, NULL);
call_user_function(EG(function_table), NULL, &function_name, return_value, 1, params);
intern->nApplyCount--;
} else if (use_arg == SPL_ARRAY_METHOD_MAY_USER_ARG) {
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "|z", &arg) == FAILURE) {
@ -1490,7 +1490,7 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam
ZVAL_COPY_VALUE(&params[1], arg);
}
intern->nApplyCount++;
call_user_function_ex(EG(function_table), NULL, &function_name, return_value, arg ? 2 : 1, params, 1, NULL);
call_user_function(EG(function_table), NULL, &function_name, return_value, arg ? 2 : 1, params);
intern->nApplyCount--;
} else {
if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "z", &arg) == FAILURE) {
@ -1499,7 +1499,7 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam
}
ZVAL_COPY_VALUE(&params[1], arg);
intern->nApplyCount++;
call_user_function_ex(EG(function_table), NULL, &function_name, return_value, 2, params, 1, NULL);
call_user_function(EG(function_table), NULL, &function_name, return_value, 2, params);
intern->nApplyCount--;
}

View File

@ -1521,7 +1521,6 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren)
ZVAL_STRINGL(&zpath, intern->file_name, intern->file_name_len);
spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), return_value, &zpath, &zflags);
zval_ptr_dtor(&zpath);
zval_ptr_dtor(&zflags);
subdir = Z_SPLFILESYSTEM_P(return_value);
if (subdir) {

View File

@ -1146,7 +1146,6 @@ SPL_METHOD(SplDoublyLinkedList, serialize)
/* flags */
ZVAL_LONG(&flags, intern->flags);
php_var_serialize(&buf, &flags, &var_hash);
zval_ptr_dtor(&flags);
/* elements */
while (current) {

View File

@ -877,7 +877,6 @@ static zval *spl_fixedarray_it_get_current_data(zend_object_iterator *iter) /* {
ZVAL_LONG(&zindex, object->current);
data = spl_fixedarray_object_read_dimension_helper(object, &zindex);
zval_ptr_dtor(&zindex);
if (data == NULL) {
data = &EG(uninitialized_zval);
@ -983,8 +982,6 @@ SPL_METHOD(SplFixedArray, current)
value = spl_fixedarray_object_read_dimension_helper(intern, &zindex);
zval_ptr_dtor(&zindex);
if (value) {
ZVAL_DEREF(value);
ZVAL_COPY(return_value, value);

View File

@ -2509,7 +2509,6 @@ static inline void spl_limit_it_seek(spl_dual_it_object *intern, zend_long pos)
ZVAL_LONG(&zpos, pos);
spl_dual_it_free(intern);
zend_call_method_with_1_params(&intern->inner.zobject, intern->inner.ce, NULL, "seek", NULL, &zpos);
zval_ptr_dtor(&zpos);
if (!EG(exception)) {
intern->current.pos = pos;
if (spl_limit_it_valid(intern) == SUCCESS) {

View File

@ -713,7 +713,6 @@ SPL_METHOD(SplObjectStorage, serialize)
smart_str_appendl(&buf, "x:", 2);
ZVAL_LONG(&flags, zend_hash_num_elements(&intern->storage));
php_var_serialize(&buf, &flags, &var_hash);
zval_ptr_dtor(&flags);
zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);

View File

@ -218,7 +218,6 @@ PHP_FUNCTION(assert)
if (Z_TYPE(ASSERTG(callback)) != IS_UNDEF) {
zval args[4];
zval retval;
int i;
uint32_t lineno = zend_get_executed_lineno();
const char *filename = zend_get_executed_filename();
@ -231,15 +230,14 @@ PHP_FUNCTION(assert)
/* XXX do we want to check for error here? */
if (!description) {
call_user_function(CG(function_table), NULL, &ASSERTG(callback), &retval, 3, args);
for (i = 0; i <= 2; i++) {
zval_ptr_dtor(&(args[i]));
}
zval_ptr_dtor(&(args[2]));
zval_ptr_dtor(&(args[0]));
} else {
ZVAL_STR(&args[3], zval_get_string(description));
call_user_function(CG(function_table), NULL, &ASSERTG(callback), &retval, 4, args);
for (i = 0; i <= 3; i++) {
zval_ptr_dtor(&(args[i]));
}
zval_ptr_dtor(&(args[3]));
zval_ptr_dtor(&(args[2]));
zval_ptr_dtor(&(args[0]));
}
zval_ptr_dtor(&retval);

View File

@ -139,11 +139,10 @@ static void userfilter_dtor(php_stream_filter *thisfilter)
ZVAL_STRINGL(&func_name, "onclose", sizeof("onclose")-1);
call_user_function_ex(NULL,
call_user_function(NULL,
obj,
&func_name,
&retval,
0, NULL,
0, NULL);
zval_ptr_dtor(&retval);
@ -344,11 +343,10 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
/* invoke the constructor */
ZVAL_STRINGL(&func_name, "oncreate", sizeof("oncreate")-1);
call_user_function_ex(NULL,
call_user_function(NULL,
&obj,
&func_name,
&retval,
0, NULL,
0, NULL);
if (Z_TYPE(retval) != IS_UNDEF) {

View File

@ -678,7 +678,7 @@ static int php_var_serialize_call_sleep(zval *retval, zval *struc) /* {{{ */
ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1);
BG(serialize_lock)++;
res = call_user_function_ex(CG(function_table), struc, &fname, retval, 0, 0, 1, NULL);
res = call_user_function(CG(function_table), struc, &fname, retval, 0, 0);
BG(serialize_lock)--;
zval_dtor(&fname);

View File

@ -221,7 +221,7 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
}
BG(serialize_lock)++;
if (call_user_function_ex(CG(function_table), zv, &wakeup_name, &retval, 0, 0, 1, NULL) == FAILURE || Z_ISUNDEF(retval)) {
if (call_user_function(CG(function_table), zv, &wakeup_name, &retval, 0, 0) == FAILURE || Z_ISUNDEF(retval)) {
wakeup_failed = 1;
GC_ADD_FLAGS(Z_OBJ_P(zv), IS_OBJ_DESTRUCTOR_CALLED);
}

View File

@ -219,7 +219,7 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
}
BG(serialize_lock)++;
if (call_user_function_ex(CG(function_table), zv, &wakeup_name, &retval, 0, 0, 1, NULL) == FAILURE || Z_ISUNDEF(retval)) {
if (call_user_function(CG(function_table), zv, &wakeup_name, &retval, 0, 0) == FAILURE || Z_ISUNDEF(retval)) {
wakeup_failed = 1;
GC_ADD_FLAGS(Z_OBJ_P(zv), IS_OBJ_DESTRUCTOR_CALLED);
}

View File

@ -476,7 +476,7 @@ static void php_wddx_serialize_object(wddx_packet *packet, zval *obj)
* We try to call __sleep() method on object. It's supposed to return an
* array of property names to be serialized.
*/
if (call_user_function_ex(CG(function_table), obj, &fname, &retval, 0, 0, 1, NULL) == SUCCESS) {
if (call_user_function(CG(function_table), obj, &fname, &retval, 0, 0) == SUCCESS) {
if (!Z_ISUNDEF(retval) && (sleephash = HASH_OF(&retval))) {
php_wddx_add_chunk_static(packet, WDDX_STRUCT_S);
snprintf(tmp_buf, WDDX_BUF_LEN, WDDX_VAR_S, PHP_CLASS_NAME_VAR);
@ -926,7 +926,7 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
ZVAL_STRING(&fname, "__wakeup");
call_user_function_ex(NULL, &ent1->data, &fname, &retval, 0, 0, 0, NULL);
call_user_function(NULL, &ent1->data, &fname, &retval, 0, 0);
zval_ptr_dtor(&fname);
zval_ptr_dtor(&retval);

View File

@ -689,11 +689,11 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count)
ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1);
call_result = call_user_function_ex(NULL,
call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
0, NULL, 0, NULL);
0, NULL);
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval)) {
stream->eof = 1;
@ -721,11 +721,11 @@ static int php_userstreamop_close(php_stream *stream, int close_handle)
ZVAL_STRINGL(&func_name, USERSTREAM_CLOSE, sizeof(USERSTREAM_CLOSE)-1);
call_user_function_ex(NULL,
call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
0, NULL, 0, NULL);
0, NULL);
zval_ptr_dtor(&retval);
zval_ptr_dtor(&func_name);
@ -749,11 +749,11 @@ static int php_userstreamop_flush(php_stream *stream)
ZVAL_STRINGL(&func_name, USERSTREAM_FLUSH, sizeof(USERSTREAM_FLUSH)-1);
call_result = call_user_function_ex(NULL,
call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
0, NULL, 0, NULL);
0, NULL);
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval))
call_result = 0;
@ -816,11 +816,11 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when
/* now determine where we are */
ZVAL_STRINGL(&func_name, USERSTREAM_TELL, sizeof(USERSTREAM_TELL)-1);
call_result = call_user_function_ex(NULL,
call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
0, NULL, 0, NULL);
0, NULL);
if (call_result == SUCCESS && Z_TYPE(retval) == IS_LONG) {
*newoffs = Z_LVAL(retval);
@ -886,11 +886,11 @@ static int php_userstreamop_stat(php_stream *stream, php_stream_statbuf *ssb)
ZVAL_STRINGL(&func_name, USERSTREAM_STAT, sizeof(USERSTREAM_STAT)-1);
call_result = call_user_function_ex(NULL,
call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
0, NULL, 0, NULL);
0, NULL);
if (call_result == SUCCESS && Z_TYPE(retval) == IS_ARRAY) {
if (SUCCESS == statbuf_from_array(&retval, ssb))
@ -920,7 +920,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
switch (option) {
case PHP_STREAM_OPTION_CHECK_LIVENESS:
ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1);
call_result = call_user_function_ex(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, 0, NULL, 0, NULL);
call_result = call_user_function(NULL, Z_ISUNDEF(us->object)? NULL : &us->object, &func_name, &retval, 0, NULL);
if (call_result == SUCCESS && (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE)) {
ret = zval_is_true(&retval) ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
} else {
@ -1412,11 +1412,10 @@ static size_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t cou
ZVAL_STRINGL(&func_name, USERSTREAM_DIR_READ, sizeof(USERSTREAM_DIR_READ)-1);
call_result = call_user_function_ex(NULL,
call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
0, NULL,
0, NULL);
if (call_result == SUCCESS && Z_TYPE(retval) != IS_FALSE && Z_TYPE(retval) != IS_TRUE) {
@ -1445,11 +1444,11 @@ static int php_userstreamop_closedir(php_stream *stream, int close_handle)
ZVAL_STRINGL(&func_name, USERSTREAM_DIR_CLOSE, sizeof(USERSTREAM_DIR_CLOSE)-1);
call_user_function_ex(NULL,
call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
0, NULL, 0, NULL);
0, NULL);
zval_ptr_dtor(&retval);
zval_ptr_dtor(&func_name);
@ -1469,11 +1468,11 @@ static int php_userstreamop_rewinddir(php_stream *stream, zend_off_t offset, int
ZVAL_STRINGL(&func_name, USERSTREAM_DIR_REWIND, sizeof(USERSTREAM_DIR_REWIND)-1);
call_user_function_ex(NULL,
call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
0, NULL, 0, NULL);
0, NULL);
zval_ptr_dtor(&retval);
zval_ptr_dtor(&func_name);