Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49959 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36389 invoked from network); 22 Oct 2010 23:05:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Oct 2010 23:05:34 -0000 Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.21 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.21 smtp1.ist.utl.pt Linux 2.6 Received: from [193.136.128.21] ([193.136.128.21:44431] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id ED/E8-08242-AB812CC4 for ; Fri, 22 Oct 2010 19:05:32 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 0B1087000498 for ; Sat, 23 Oct 2010 00:05:28 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp1.ist.utl.pt ([127.0.0.1]) by localhost (smtp1.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id Gd1Nu9mDpLNA for ; Sat, 23 Oct 2010 00:05:27 +0100 (WEST) Received: from mail2.ist.utl.pt (mail2.ist.utl.pt [IPv6:2001:690:2100:1::c]) by smtp1.ist.utl.pt (Postfix) with ESMTP id C7A8E70004AE for ; Sat, 23 Oct 2010 00:05:27 +0100 (WEST) Received: from damnation.dulce.lo.geleia.net (52.152.108.93.rev.vodafone.pt [93.108.152.52]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id B46582006C5A for ; Sat, 23 Oct 2010 00:05:27 +0100 (WEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net References: <4CC2007E.2070703@divbyzero.net> Date: Sat, 23 Oct 2010 00:05:29 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_IST?= Message-ID: In-Reply-To: <4CC2007E.2070703@divbyzero.net> User-Agent: Opera Mail/10.63 (Win32) Subject: Re: [PHP-DEV] Storing zvals in hash tables in resources From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Fri, 22 Oct 2010 22:22:06 +0100, Martin Jansen wrote: > I'm trying to store zvals in a hash table which is part of a resource. > Unfortunately the zvals do not seem to "persist" between function calls: > > [...] > > ALLOC_HASHTABLE(ctx->variables); > zend_hash_init(ctx->variables, 32, NULL, NULL, 0); > You probably want to give a destructor to zend_hash_init, since you're storing zvals, that would be ZVAL_PTR_DTOR. > [...] > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsz", > &zcontext, &name, &name_len, &value) == FAILURE) > { > return; > } > > ZEND_FETCH_RESOURCE(ctx, foo_context*, &zcontext, -1, > FOO_CONTEXT_RES_NAME, le_adl_context); > > zend_hash_update(ctx->variables, name, name_len + 1, &value, > sizeof(zval*), NULL); You're not incrementing the refcount of the value you're adding to the hash table. Call zval_add_ref. -- Gustavo Lopes