Re: from one hash to another, in an extension
| From: | Andrei Zmievski | Date: | Wed, 23 Oct 2002 20:46:10 +0000 |
| Subject: | Re: from one hash to another, in an extension | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-90027@lists.php.net to get a copy of this message | ||
On Wed, 23 Oct 2002, Tim Daly, Jr. wrote:
>
> I'm trying to figure out the right way to take an entry from one hash
> table, and put it in another, in C. This is what I first tried:
>
> // naive attempt at
> // $hash2["key"] = $hash1["key"];
>
> zval **val;
>
> zend_hash_find(hash1, "key", strlen("key")+1, (void **)&val);
> SEPARATE_ZVAL(val);
> zval_add_ref(val);
> zend_hash_update(hash2, "key", strlen("key")+1, (void *)val, NULL);
>
>
> That seemed to work. But I started having strange problems in my PHP
> code, like I would assign the property of an object, and later the
> same property would be magically null again. This problem goes away
> when I remove the SEPARATE_ZVAL above.
>
> So, I though maybe one of you kind folks might shed some light on this
> for me.
You don't need to SEPARATE_ZVAL() in this case.
--
Andrei Zmievski Mail: andrei.zmievski@fastsearch.com
Sr. Front End Software Engineer Web: http://www.fast.no/
Fast Search & Transfer Inc Phone: 781-304-2493
93 Worcester Street Fax: 781-304-2410
Wellesley MA 02481-9181, USA Main: 781-304-2400