Skip to content

Commit 76fe989

Browse files
committed
Add zend_call_function_with_return_value()
This API handles the common case of calling a userland function and passing a return value pointer. This allows to remove the 'incorrect' usage of zend_fcall_info_call(fci, fcc, retval, NULL)
1 parent 9e6588b commit 76fe989

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Zend/zend_API.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,15 @@ ZEND_API zend_result zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_
733733
* will be UNDEF. Otherwise, the retval will be a non-UNDEF value. */
734734
ZEND_API zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache);
735735

736+
/* Call the FCI/FCC pair while setting the call return value to the passed zval*. */
737+
static zend_always_inline zend_result zend_call_function_with_return_value(
738+
zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zval *retval)
739+
{
740+
ZEND_ASSERT(retval && "Use zend_call_function() directly if not providing a retval");
741+
fci->retval = retval;
742+
return zend_call_function(fci, fci_cache);
743+
}
744+
736745
/* Call the provided zend_function with the given params.
737746
* If retval_ptr is NULL, the return value is discarded.
738747
* If object is NULL, this must be a free function or static call.

0 commit comments

Comments
 (0)