0

Is the zval * value returned by the zend api method zend_call_method same as the zval *retval argument passed into it?

I can see that zend_call_method is declared in zend_interfaces.h. I tried grepping the source directory for its definition, but couldn't find it. Where is it defined?

I have seen some extensions using the same variable as retval argument, and also to receive the return value of the function call. Is that the expected usage?

Joyce Babu
  • 19,602
  • 13
  • 62
  • 97

1 Answers1

0

I just found out that they are not the same.

When calling DateTime::setTimezone with zend_call_method, passing the zval * of the original DateTime object as *retval increments it's refcount by 1.

zend_call_method_with_1_params(date, php_date_get_date_ce(), NULL, "settimezone", date, tz);

Whereas the following code does not

date = zend_call_method_with_1_params(date, php_date_get_date_ce(), NULL, "settimezone", NULL, tz);
Joyce Babu
  • 19,602
  • 13
  • 62
  • 97