RE: [PHP-CVS] cvs: php4 /ext/session session.c
| From: | Sterling Hughes | Date: | Sat, 18 Nov 2000 18:09:06 +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-2687@lists.php.net to get a copy of this message | ||
> + 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;)?
>BTW: we are going into Zend guts more or less anyway in serializing
>variables, it's inevitable. But I agree this code is ugly - it has to do
>ugly thing, so it is.
Perhaps then Zend should have a set of serialization functions (or an
intermediate structure where the contents of a variable can be stored),
enough of the extensions rely on this feature.
-Sterling