Re: Segfault when assigning a reference variable
| From: | Johannes Schlüter | Date: | Fri, 07 Mar 2014 19:07:50 +0000 |
| Subject: | Re: Segfault when assigning a reference variable | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-11608@lists.php.net to get a copy of this message | ||
Hi,
On Fri, 2014-03-07 at 14:52 -0400, JGM wrote:
> I'm trying to implement a virtual method on wxphp that in C++ looks like:
>
> size_t wxInputStream::OnSysRead(void* buffer, size_t bufsize)
>
> so in php this method is implemented as:
>
> public function OnSysRead(&$buffer, $bufsize)
Why do you need a reference here? You can return the buffer by value.
Copy on write will prevent unneeded copies and reference trouble and as
PHP strings are binary safe there is no need to transport the length
independently.
johannes