Re: Different between add_assoc_zval() and add_assoc_string()
| From: | Stas Malyshev | Date: | Fri, 31 Jan 2014 08:38:57 +0000 |
| Subject: | Re: Different between add_assoc_zval() and add_assoc_string() | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-11479@lists.php.net to get a copy of this message | ||
Hi!
> I use add_assoc_string() when the argument is string,and it works
fine,but when the argument is a array,and i use
> add_assoc_zval(),the result is not what i want.
It would be useful to describe here what "not what I want" looks like.
> here is my code:
> if(Z_TYPE_P(value) == IS_STRING){
> add_assoc_string(config, key, Z_STRVAL_P(value), 1);
> RETURN_ZVAL(config, 1, 0);
> return;
> }else if(Z_TYPE_P(value) == IS_ARRAY){
> add_assoc_zval(config, key, value);
> RETURN_ZVAL(config, 1, 0);
> return;
> }
>
> what could the problem be?
For one, value's refcount should be bumped if you are keeping it,
otherwise the engine doesn't know there's another use of this zval.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227