Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34819 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76567 invoked by uid 1010); 17 Jan 2008 20:33:51 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 76552 invoked from network); 17 Jan 2008 20:33:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jan 2008 20:33:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=ioplex@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ioplex@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.162.225 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.162.225 nz-out-0506.google.com Received: from [64.233.162.225] ([64.233.162.225:16006] helo=nz-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F9/BC-18592-B9BBF874 for ; Thu, 17 Jan 2008 15:33:32 -0500 Received: by nz-out-0506.google.com with SMTP id x7so582359nzc.38 for ; Thu, 17 Jan 2008 12:33:29 -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:mime-version:content-type:content-transfer-encoding:content-disposition; bh=klHbP91Fjy2GZJWahDx/dsiIIZtKnqrKRxZol9mNXiM=; b=WFiV35HXp3wOcuokyKyRK27b3RiIwkopcSwrefxuhTbOf78rcC3wsJQ56WYWn0QOZ6drx55/eHB4JkqGbZsy+1ynFB17x41w12fTmvMrnezi1BdwGx+MBaAq278+aqyXBqyBfh63m3zOqXTNnjvndnXjOLxSUXi4Y/0Hszh4eBY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=pGQqW4k57ag6VhcIS/0KGiflXzzqipgnKxNqW8XQKsNYIWN0UYGBxE/5Pz7X1DlRSsHfnRG65RM21sDYv5/T91L49SyqfCtMHjnczuOe2GKupTNZ3Q6lGimqfS8fHOwOjTrPrEM+HR9vp1gCPccU3IHFV8jyU1m9HkF4winz0Fk= Received: by 10.142.191.2 with SMTP id o2mr1563199wff.132.1200602008699; Thu, 17 Jan 2008 12:33:28 -0800 (PST) Received: by 10.142.133.21 with HTTP; Thu, 17 Jan 2008 12:33:28 -0800 (PST) Message-ID: <78c6bd860801171233p6f652d3bl54559d51963c1300@mail.gmail.com> Date: Thu, 17 Jan 2008 15:33:28 -0500 To: internals@lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Referencing constants in extension code From: ioplex@gmail.com ("Michael B Allen") Hi, It seems something has changed recently regarding referencing constants that has broken my extension and I'm trying to figure out exactly what the right thing to do is. When passing a string constant to an extension function, within the extension I have been saving that string directly for possible retrieval later (see code below). This has worked fine but it seems with recent releases of PHP (5.2.5 is what I'm testing with) the memory the string points to gets clobbered after the function returns. Meaning when I retrieve the value later it is garbage data. I suppose thinking a string parameter would be valid after the call was a bold assumption but it worked. Has something changed regarding parameters that are constants? Or was my code always broken and it's just a coincidence that I'm seeing corrupted values now? How can I convert a string constant to a value that I can save internally? Must I simply copy the string always? Does zend_get_constant help? Mike 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 } RETURN_STRING(foo_status(foo), 1); }