RE: [PHP-CVS] cvs: php4 /ext/session session.c
| From: | Sterling Hughes | Date: | Sat, 18 Nov 2000 23:39:29 +0000 |
| Subject: | RE: [PHP-CVS] cvs: php4 /ext/session session.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-2693@lists.php.net to get a copy of this message | ||
At 19:09 18/11/00 +0100, Sterling Hughes wrote:
> > + is_ref = (*old_symbol)->is_ref;
> > + refcount = (*old_symbol)->refcount;
> > + **old_symbol = *state_val_copy;
> > + (*old_symbol)->is_ref = is_ref;
> > + (*old_symbol)->refcount = refcount;
>SS>> I think this kind of logic should be in Zend, and not in the
>SS>> extension code. While the task of changing an existing symbol
>SS>> might be complex, it should be simple for an extension to
>SS>> perform that step.
>
> >You might be right, though Zend does not have such an opearion in it's
> >API presently. So if somebody (Zeev, Andi?) can generalize this and add
> >such an op to Zend, it would be good. Generally, what I need is to
replace
> >variable contents while preserving it's refcount and is_ref.
> >
>
>I don't have a compilation enviroment handy, but:
>
>ZEND_API void zval_swap_contents(zval *var1, zval *var2)
>{
> int is_ref,
> refcount;
>
> zval_dtor(var1);
>
> is_ref = var1->is_ref;
> refcount = var1->refcount;
>
> *var1 = *var2;
>
> var1->is_ref = is_ref;
> var2->refcount = refcount;
>}
>
>
>Should do the trick, shouldn't it (famous last words;)?
Not quite, and it probably should be a macro. We'll try and work out
something nice and useable.
Andi
--
Ok, that was a quick sketch. It's going to be an ugly macro though
(however, nothing uglier than I've written ;)...
-Sterling