Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13015 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30886 invoked by uid 1010); 27 Sep 2004 16:44:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 27898 invoked from network); 27 Sep 2004 16:43:47 -0000 Received: from unknown (HELO mail.omniti.com) (66.80.117.3) by pb1.pair.com with SMTP; 27 Sep 2004 16:43:47 -0000 Received: from ([66.80.117.2:57063]) by mail.omniti.com (ecelerity HEAD) with SMTP id 59/12-22587-54348514 for ; Mon, 27 Sep 2004 12:43:53 -0400 In-Reply-To: <20040927161429.GA70753@gravitonic.com> References: <20040927161429.GA70753@gravitonic.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-ID: <47810498-10A4-11D9-9466-000D93359332@omniti.com> Content-Transfer-Encoding: 7bit Cc: Robert Silva , George Schlossnagle , internals@lists.php.net Date: Mon, 27 Sep 2004 12:42:54 -0400 To: Andrei Zmievski X-Mailer: Apple Mail (2.619) Subject: Re: [PHP-DEV] Newbie help From: george@omniti.com (George Schlossnagle) On Sep 27, 2004, at 12:14 PM, Andrei Zmievski wrote: > On Sun, 26 Sep 2004, Robert Silva wrote: >> Trying to register a constant value for a class and it keeps crashing. >> Learning C as I go, so I would appreciate some insight. I can figure >> out >> that my *property value is lost during zend_hash_add() but my >> knowledge >> stops there as to why. Tried passing property as property and >> &property. >> >> ZEND_METHOD(zboolean, __construct) >> { >> zval *object = getThis(); >> zval *property >> >> ALLOC_ZVAL(property); >> INIT_PZVAL(property); >> ZVAL_STRING(property, "true", 1); >> zend_hash_add(&(Z_OBJCE_P(object))->constants_table, "TrueString", >> sizeof("TrueString")+1, property, sizeof(zval *)); >> } > > zend_hash_add(&(Z_OBJECE_P(object))->constants_table, "TrueString", > sizeof("TrueString"), &property, sizeof(zval *), NULL); The key being that sizeof("Foo") == strlen("Foo") + 1 George