Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34822 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72076 invoked by uid 1010); 18 Jan 2008 01:39:27 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 72061 invoked from network); 18 Jan 2008 01:39:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jan 2008 01:39:27 -0000 Authentication-Results: pb1.pair.com header.from=ioplex@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ioplex@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.166.178 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ioplex@gmail.com X-Host-Fingerprint: 64.233.166.178 py-out-1112.google.com Received: from [64.233.166.178] ([64.233.166.178:30816] helo=py-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/0A-18592-E4300974 for ; Thu, 17 Jan 2008 20:39:27 -0500 Received: by py-out-1112.google.com with SMTP id u77so998406pyb.16 for ; Thu, 17 Jan 2008 17:39:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=4G+mVw4h6tyiXD0dARjtGDmewBUsxIIm13wNq+nmwE4=; b=Az21s1QAGaTBh9P/iwm5H90HwVDafFG6UlR1JsfufiYcxMwJIB+5sWb8cg2JaOtDa82O/Xq5E715NWZhin0OUmW3p0IZOFQCSJ4nHKVp+UGTLUsKIgRukUonR1Hc10Wt+4oI1k+2k9mmpWUYa15qhKKKXOhlrrIzDWpYkdh5dCA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ZWxWFpwa5kZQ2Z6NxKz9DLTDnrnxe3XoGyCi7XjvruqTQjkiau/G9PrxIuS82er6iL7i3QGN0WE8oSKC3JdkwBLl74Q06jDHxYNBEBDMk1Ae9Ki5FoVHCXUR3SqVZl1Vk16gzN22L0Yekj8Pbg7GceWPeojliey922en0nshqFc= Received: by 10.143.33.19 with SMTP id l19mr1744642wfj.9.1200620364074; Thu, 17 Jan 2008 17:39:24 -0800 (PST) Received: by 10.142.133.21 with HTTP; Thu, 17 Jan 2008 17:39:23 -0800 (PST) Message-ID: <78c6bd860801171739o3e746302v449afd6f62eaa30b@mail.gmail.com> Date: Thu, 17 Jan 2008 20:39:23 -0500 To: "Antony Dovgal" , internals@lists.php.net In-Reply-To: <478FC8E4.3050104@daylessday.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <78c6bd860801171233p6f652d3bl54559d51963c1300@mail.gmail.com> <478FC8E4.3050104@daylessday.org> Subject: Re: [PHP-DEV] Referencing constants in extension code From: ioplex@gmail.com ("Michael B Allen") On 1/17/08, Antony Dovgal wrote: > On 17.01.2008 23:33, Michael B Allen wrote: > > This has worked fine > > Are you really sure? It has worked just fine under load in production with PHP 5, 5.0 and 5.1. It *seems* there's something different about 5.2. > Does valgrind confirm it? I have run valgrind (primarily for leak checking) and I don't recall seeing any complaints about the code or objects in question. > > PHP_FUNCTION(foo_status) > > { > > zval *r; > > char *s = ""; > > int slen; > > struct foo *foo = NULL; > > > > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!|s!", > > &r, &s, &slen) == FAILURE) { > > RETURN_FALSE; > > } > > > > if (r) > > foo = (struct foo *)zend_fetch_resource(&r TSRMLS_CC, > > -1, "foo", NULL, 1, le_foo); > > > > if (ZEND_NUM_ARGS() > 1) { > > foo_status(foo) = s; // save the status for possible retrieval later > > } > > I don't know what "foo_status(foo)" is supposed to mean here, It's saving s into foo. It's actually an errno style macro that dereferences a char ** to assign the value to a member of foo. > but this code was never supposed to work. Well it did. > You have to copy the string if you want to store it. Ok. Doesn't look like I have much choice. I just wanted to understand the problem better. I'll just copy the strings. But it does seem odd to me that PHP does not always reference string constants directly. I mean, why copy if you don't have to? Mike