On 1/17/08, Antony Dovgal <[EMAIL PROTECTED]> wrote:
> On 17.01.2008 23:33, Michael B Allen wrote:
> > This has worked fine
>
> Are you really sure?

It has worked just fine under load in production with PHP 5, 5.0 and
5.1. It *seems* there's something different about 5.2.

> Does valgrind confirm it?

I have run valgrind (primarily for leak checking) and I don't recall
seeing any complaints about the code or objects in question.

> > PHP_FUNCTION(foo_status)
> > {
> >     zval *r;
> >     char *s = "";
> >     int slen;
> >     struct foo *foo = NULL;
> >
> >     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!|s!",
> >                 &r, &s, &slen) == FAILURE) {
> >         RETURN_FALSE;
> >     }
> >
> >     if (r)
> >         foo = (struct foo *)zend_fetch_resource(&r TSRMLS_CC,
> >                 -1, "foo", NULL, 1, le_foo);
> >
> >     if (ZEND_NUM_ARGS() > 1) {
> >         foo_status(foo) = s; // save the status for possible retrieval later
> >     }
>
> I don't know what "foo_status(foo)" is supposed to mean here,

It's saving s into foo. It's actually an errno style macro that
dereferences a char ** to assign the value to a member of foo.

> but this code was never supposed to work.

Well it did.

> You have to copy the string if you want to store it.

Ok. Doesn't look like I have much choice. I just wanted to understand
the problem better. I'll just copy the strings.

But it does seem odd to me that PHP does not always reference string
constants directly. I mean, why copy if you don't have to?

Mike

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to