diff options
author | Xinchen Hui <laruence@php.net> | 2014-05-07 16:52:58 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2014-05-07 16:52:58 +0800 |
commit | ed5b6af8af6a0b8c331e692cd0a81daeef59dcff (patch) | |
tree | 194de70013427ca022b98b1913f119c53a69d25a /ext/filter/callback_filter.c | |
parent | 8b90b17c8d7cc3def0d81256a021a7e86a2401a1 (diff) | |
download | php-git-ed5b6af8af6a0b8c331e692cd0a81daeef59dcff.tar.gz |
Refactored filter
Diffstat (limited to 'ext/filter/callback_filter.c')
-rw-r--r-- | ext/filter/callback_filter.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c index 37c0631d6f..49410dbfe6 100644 --- a/ext/filter/callback_filter.c +++ b/ext/filter/callback_filter.c @@ -22,35 +22,30 @@ void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) { - zval *retval_ptr; - zval ***args; + zval retval; + zval *args; int status; if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_CHECK_NO_ACCESS, NULL TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is expected to be a valid callback"); - zval_dtor(value); - Z_TYPE_P(value) = IS_NULL; + zval_ptr_dtor(value); + ZVAL_NULL(value); return; } - args = safe_emalloc(sizeof(zval **), 1, 0); - args[0] = &value; - - status = call_user_function_ex(EG(function_table), NULL, option_array, &retval_ptr, 1, args, 0, NULL TSRMLS_CC); + args = safe_emalloc(sizeof(zval), 1, 0); + ZVAL_COPY(&args[0], value); + status = call_user_function_ex(EG(function_table), NULL, option_array, &retval, 1, args, 0, NULL TSRMLS_CC); - if (status == SUCCESS && retval_ptr != NULL) { - if (retval_ptr != value) { - zval_dtor(value); - ZVAL_COPY_VALUE(value, retval_ptr); -//??? COPY_PZVAL_TO_ZVAL(*value, retval_ptr); - } else { - zval_ptr_dtor(&retval_ptr); - } + if (status == SUCCESS && !Z_ISUNDEF(retval)) { + zval_ptr_dtor(value); + ZVAL_COPY_VALUE(value, &retval); } else { - zval_dtor(value); - Z_TYPE_P(value) = IS_NULL; + zval_ptr_dtor(value); + ZVAL_NULL(value); } + zval_ptr_dtor(&args[0]); efree(args); } |