Agree, it would be nice to have a zend_declare_constant function.

Yea, I moved it to MINIT for the module afterwards (thinking that may the
problem). Been tracing it in VS for many hours now, and essentially it still
crashes when it goes to destroy the hash at shutdown. Somewhere between
declaring the constant in the constants_table (which works, <?=
Zboolean::TrueString; ?> prints "true"

But by the time it gets to zend_hash_destroy in destroy_zend_class (running
in ZTS mode) the zval in the constants_table is missing. At this point, I'm
pretty sure its not me :) I am going to compile my classes under linux and
see if it crashes, I'm thinking it wont.

I'll spend a few more hours tracing the code and try to find out whats up.

Thanks for the help and ideas.

Bob


-----Original Message-----
From: Alan Knowles [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 27, 2004 4:31 PM
To: George Schlossnagle
Cc: Andrei Zmievski; Robert Silva; [EMAIL PROTECTED]
Subject: Re: [PHP-DEV] Newbie help

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
>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to