Skip to content

Always provide retval ptr #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

nikic
Copy link
Member

@nikic nikic commented Aug 26, 2013

Previous some places passed return_value_ptr only if the function returned by reference. Now return_value_ptr is always set, even for functions returning by-value.

This allows you to return zvals without copying their contents. For this purpose two new macros
RETVAL_ZVAL_FAST and RETURN_ZVAL_FAST are added:

RETVAL_ZVAL_FAST(zv); /* Analog to RETVAL_ZVAL(zv, 1, 0) */
RETURN_ZVAL_FAST(zv); /* Analog to RETURN_ZVAL(zv, 1, 0) */

These macros behave similarly to the non-FAST versions with copy=1 and dtor=0, with the difference that the FAST versions will try return the zval without copying by utilizing return_value_ptr.

nikic added 2 commits August 26, 2013 19:13
Previous some places passed return_value_ptr only if the function
returned by reference. Now return_value_ptr is always set, even
for functions returning by-reference.

This allows you to return zvals without copying their contents. For
this purpose two new macros RETVAL_ZVAL_FAST and RETURN_ZVAL_FAST
are added:

    RETVAL_ZVAL_FAST(zv); /* Analog to RETVAL_ZVAL(zv, 1, 0) */
	RETURN_ZVAL_FAST(zv); /* Analog to RETURN_ZVAL(zv, 1, 0) */

These macros behave similarly to the non-FAST versions with
copy=1 and dtor=0, with the difference that the FAST versions
will try return the zval without copying by utilizing return_value_ptr.
@kaplanlior
Copy link
Contributor

I'm not a programmer, so sorry my innocent question - isn't this a BC break ?

@nikic
Copy link
Member Author

nikic commented Aug 27, 2013

@kaplanlior I don't see how this would break BC. Can you provide more info on what you mean?

@laruence
Copy link
Member

maybe, some extensions use

 if (return_value_ptr)  { do some stuff returning ref }

however, I don't think it is a big issue

@php-pulls
Copy link

Comment on behalf of nikic at php.net:

merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants