Re: zval_copy_ctor

From: Date: Sat, 12 May 2001 03:31:57 +0000
Subject: Re: zval_copy_ctor
Groups: php.dev 
Request: Send a blank email to php-dev+get-54980@lists.php.net to get a copy of this message
Sorry, default=segfault.... spellcheck got me -Jason ----- Original Message ----- From: "Jason Greene" <jason@inetgurus.net> To: "Wez Furlong" <wez@thebrainroom.com>; <php-dev@lists.php.net> Sent: Friday, May 11, 2001 10:29 PM Subject: Re: [PHP-DEV] zval_copy_ctor > zval_copy_ctor used on an array makes a reference copy of the array. > Basically, it just copies all the data items in the hashtable and then adds one to the > reference count for all data items. > > Looking at the code, it appears to not recursively copy into nested arrays. > (Could be part of your problem) > Since this is a reference copy, you can not free the memory used by > the array you are copying. I am assuming that this is the cause of your default. > > -Jason > > > > ----- Original Message ----- > From: "Wez Furlong" <wez@thebrainroom.com> > To: <php-dev@lists.php.net> > Sent: Friday, May 11, 2001 8:42 PM > Subject: [PHP-DEV] zval_copy_ctor > > > > Hi, > > > > In my mailparse extension I am building up an array to contain the headers > > while parsing the message. The array is held in a zval in the internal C > > structure, one for each message part. > > > > When the "user space" code requests info for a particular message part it > > is returned as an assoc. array. One of the keys contains the headers; > > > > eg: > > > > $info => array( > > "content-type" => "text/plain", > > "headers" => array( > > "to" => "wez@php.net", > > "from" => php-dev@lists.php.net" > > ) > > ); > > > > So far, to do this I am using this code: > > > > zval * headers; > > > > MAKE_STD_ZVAL(headers); > > *headers = *rfcbuf->headers; > > if (zval_copy_ctor(headers) == SUCCESS) { > > zend_hash_update(HASH_OF(return_value), "headers", > > strlen("headers") + 1, &headers, sizeof(headers) > > NULL); > > } > > > > where rfcbuf->headers is a "zval *" created using MAKE_STD_ZVAL and > > array_init. > > > > It seems to work OK. > > > > Is it correct? The ZendAPI docs aren't 100% clear about using the copy > > constructor, and I am experiencing intermittent segfaults in a specific > > part of my "application" that uses this code. > > > > --Wez. > > > > > > > > -- > > PHP Development Mailing List <http://www.php.net/> > > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > > For additional commands, e-mail: php-dev-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > >

« previous php.dev (#54980) next »