Re: myext_globals->global_value vs MYEXT_G(global_value)

From: Date: Thu, 05 Aug 2010 02:41:02 +0000
Subject: Re: myext_globals->global_value vs MYEXT_G(global_value)
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-7410@lists.php.net to get a copy of this message
On Thu, 05 Aug 2010 02:23:05 +0100, j adams <zardozrocks@gmail.com> wrote:
I am wondering about the correct way to deal with global vars when writing a PECL extension.
I wrote about this a while back in the wiki. See http://wiki.php.net/internals/engine#extension_globals
And then initialized in a function I have not yet seen documented in any of the 'getting started' materials: /* {{{ PHP_GINIT_FUNCTION */ static PHP_GINIT_FUNCTION(json) {
    json_globals->error_code = 0;
} /* }}} */ This json_globals->error_code assignment puzzles me for two reasons. First, what is this PHP_GINIT_FUNCTION?
It's just a legacy name of ZEND_MODULE_GLOBALS_CTOR_D (I say "legacy" because there's a comment saying "for compatibility" before the macro is defined).
It seems to me that a last_error type var should be initiated in a MINIT function, no?
I think it's more or less indifferent, but the globals constructor is called before the module startup function (and the module shutdown is called before the globals destructor). -- Gustavo Lopes

« previous php.pecl.dev (#7410) next »