Re: Non-pointer params, zend_parse_parameters, and the "!" modifier
On Sat, 02 Feb 2013 14:36:00 +0100, Sara Golemon <[email protected]> wrote:
Gustavo's diff for scalars adds '!' support (this was ignored
previously) by letting the NULL get cast to the type (e.g.
false/0/0.0) and using a second zend_bool parameter to indicate if
NULL was passed or not:
long num = 42;
zend_bool num_was_null;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l!", &num,
&num_was_null) == FAILURE) return;
Now if the func is called with NULL as the argument, num will still be
overwritten to 0, but we'll get the flag indicating that NULL got
passed in, and we're forced to reset it to the default value (assuming
that was our intent).
[...]
Thoughts?
You raise a good point. From my part, feel free to modify it so the passed long is not changed.
--
Gustavo Lopes
Thread (3 messages)