Re: Is it the right way to pass an argument to callback?
| From: | Johannes Schlüter | Date: | Sun, 06 Nov 2011 16:08:06 +0000 |
| Subject: | Re: Is it the right way to pass an argument to callback? | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-8812@lists.php.net to get a copy of this message | ||
Hi,
On Sun, 2011-11-06 at 20:37 +0500, Ruslan Osmanov wrote:
> Hello.
>
> I wonder if I pass a callback argument here the right way:
> http://susepaste.org/99481533
I didn't look deep into it, but two comments:
* php_eio_cb_t *cb_data_ptr = emalloc(sizeof(php_eio_cb_t)); -
this will leak if zend_parse_parameters fails. Better allocate
later (or efree before return)
* For callbacks you should use the zend_parse_parameters "f"
modifier. Grepping for 'if
(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f' will give
you some examples and README.PARAMETER_PARSING_API has some
docs.
johannes