回复: [PECL-DEV] Different between add_assoc_zval() and add_assoc_string()

From: Date: Fri, 31 Jan 2014 09:35:30 +0000
Subject: 回复: [PECL-DEV] Different between add_assoc_zval() and add_assoc_string()
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-11480@lists.php.net to get a copy of this message
Thank you very much,but i hope you can specify a little more detail,cause i am a absolute newer of php extension codeing,and here is my code https://gist.github.com/yangshengjie/8728597 ------------------ 原始邮件 ------------------ 发件人: "Stas Malyshev"; 发送时间: 2014年1月31日(星期五) 下午4:38 收件人: "羊生杰"; "pecl-dev"; 主题: Re: [PECL-DEV] Different between add_assoc_zval() and add_assoc_string() 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 .

« previous php.pecl.dev (#11480) next »