Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13031 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16634 invoked by uid 1010); 27 Sep 2004 23:30:51 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 16600 invoked from network); 27 Sep 2004 23:30:50 -0000 Received: from unknown (HELO newweb.akbkhome.com) (202.81.246.113) by pb1.pair.com with SMTP; 27 Sep 2004 23:30:50 -0000 Received: from develop ([192.168.0.40] ident=alan) by newweb.akbkhome.com with esmtp (Exim 4.33) id 1CC53w-0006IJ-0e; Tue, 28 Sep 2004 07:37:44 +0800 Message-ID: <4158A2CF.1060707@akbkhome.com> Date: Tue, 28 Sep 2004 07:31:27 +0800 User-Agent: Mozilla Thunderbird 0.8 (X11/20040918) X-Accept-Language: en-us, en MIME-Version: 1.0 To: George Schlossnagle CC: Andrei Zmievski , Robert Silva , internals@lists.php.net References: <20040927161429.GA70753@gravitonic.com> <47810498-10A4-11D9-9466-000D93359332@omniti.com> In-Reply-To: <47810498-10A4-11D9-9466-000D93359332@omniti.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Newbie help From: alan@akbkhome.com (Alan Knowles) Is there a reason there is no macro for this? (took me a while to figure it out as well) And should it be done in PHP_MINIT_FUNCTION(), rather than __construct Regards Alan George Schlossnagle wrote: > > 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 >