Re: [PHP4BETA] some api stuff from php3 variables.c

From: Date: Mon, 05 Jul 1999 06:24:00 +0000
Subject: Re: [PHP4BETA] some api stuff from php3 variables.c
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-1885@lists.php.net to get a copy of this message
On Mon, 5 Jul 1999, Zeev Suraski wrote: > At 15:42 04/07/99 , Thies C. Arntzen wrote: > >hi zeev, andy, > > > Andi's gone till Thursday... > > >things like: > >php3i_long_pval & friend don't exist in php4 currently - will you put > >them into the "official" zend api? have a look in xml.c - stig uses those for creating the arguments of call_user_function. as we have no api-functions for locating array entries (_hash_find) and inserting arrays into arrays (_hash_update) i mess around with pvals quite a bit in oci8.c > > What do they do? just create and init a new pval. > > >one question, what is the "official" descructor function that modules > >should use (zend_dtor)? and what do we need to do for the ELS stuff when > >destructing? i use it in oci8.c for user-supplied defines: $s = ociparse($c,"select A from A"); ocidefinbyname($s,"A",&$avar); ociexecute($s); while (ocifetch($s)) { print $avar; // you could now do a: $avar = array("hallo", "pallo"); // i need to destruct the value when // doing my next-fetch } so before putting the new val into $avar i need to destruct the "old" value. search for pval_destructor in oci8.c and you'll see what i mean. > > I don't think you need to supply a destructor pointer anywhere - if you're > using API functions. If you need to directly destroy a zval, use > zval_dtor(). Don't supply zval_dtor() as a destructor function for symbol > table hashes though (again, I don't think any non-Zend code should be > directly supplying a hash destructor function, but should be using > array_init() or object_init() instead). > > >and again, what is the "official" way to create a new pval - as i > >mentioned before i think that: > > > >pval *value = emalloc(sizeof(pval)); > >value->type = IS_STRING; > >value->value.str.len = size; > >value->value.str.val = estrndup(column->data,size); > > > >will leave is_ref and refcount in a undefined state, which is not what we > >want - what would be the disadvantage for having an api-call for that? > > In fact, as I said, you rarely care about refcount - Zend takes care of it > for you as long as you use API functions. For example, you never have to > set up the reference count information for return_value in internal > function implementations. You also don't have to set up the reference > count information for any array elements you set using add_assoc_long() and > friends. i grepped thru the code again, and i think it's mostly xml.c and oci8.c that do this kind of internal stuff. i still think that some kind of an api for arrays in arrays would be nice: ---- from iptc.c (again it's me to blame for this code): if (_php3_hash_find(return_value->value.ht,key,strlen(key) + 1,(void **) &element) == FAILURE) { if (array_init(&values) == FAILURE) { php3_error(E_ERROR, "Unable to initialize array"); RETURN_FALSE; } _php3_hash_update(return_value->value.ht, key, strlen(key)+1, (void *) &values, sizeof(pval), (void **) &element); } add_next_index_stringl(element,buffer+inx,len,1); --- what do you think? tc > > Zeev > -- > Zeev Suraski <zeev@zend.com> http://www.zend.com/ > For a PGP public key, finger bourbon@netvision.net.il > > Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany

« previous php.version4 (#1885) next »