summaryrefslogtreecommitdiff
path: root/ext/xml
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-06-15 18:33:09 +0000
committerDmitry Stogov <dmitry@php.net>2006-06-15 18:33:09 +0000
commit1dbaae2795b756a3875c53da00b277f241cc04b8 (patch)
treefd516b57354eb9480e89dcd0503fa990d3cc2068 /ext/xml
parentc3ed91477a011e494559d6f65301ef6b2e38cd22 (diff)
downloadphp-git-1dbaae2795b756a3875c53da00b277f241cc04b8.tar.gz
Added automatic module globals management
Diffstat (limited to 'ext/xml')
-rw-r--r--ext/xml/php_xml.h6
-rw-r--r--ext/xml/xml.c25
2 files changed, 12 insertions, 19 deletions
diff --git a/ext/xml/php_xml.h b/ext/xml/php_xml.h
index a46a20d465..aa778cf825 100644
--- a/ext/xml/php_xml.h
+++ b/ext/xml/php_xml.h
@@ -45,9 +45,9 @@ extern zend_module_entry xml_module_entry;
#error "UTF-16 Unicode support not implemented!"
#endif
-typedef struct {
+ZEND_BEGIN_MODULE_GLOBALS(xml)
XML_Char *default_encoding;
-} php_xml_globals;
+ZEND_END_MODULE_GLOBALS(xml)
typedef struct {
int index;
@@ -147,7 +147,7 @@ PHPAPI char *xml_utf8_decode(const XML_Char *, int, int *, const XML_Char *);
#define phpext_xml_ptr xml_module_ptr
#ifdef ZTS
-#define XML(v) TSRMG(xml_globals_id, php_xml_globals *, v)
+#define XML(v) TSRMG(xml_globals_id, zend_xml_globals *, v)
#else
#define XML(v) (xml_globals.v)
#endif
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index 7279b04f73..8b26f5fe12 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -57,11 +57,7 @@
* - Weird things happen with <![CDATA[]]> sections.
*/
-#ifdef ZTS
-int xml_globals_id;
-#else
-PHP_XML_API php_xml_globals xml_globals;
-#endif
+ZEND_DECLARE_MODULE_GLOBALS(xml)
/* {{{ dynamically loadable module stuff */
#ifdef COMPILE_DL_XML
@@ -75,6 +71,7 @@ ZEND_GET_MODULE(xml)
/* {{{ function prototypes */
PHP_MINIT_FUNCTION(xml);
PHP_MINFO_FUNCTION(xml);
+static PHP_GINIT_FUNCTION(xml);
static void xml_parser_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
static void xml_set_handler(zval **, zval **);
@@ -161,7 +158,11 @@ zend_module_entry xml_module_entry = {
NULL, /* per-request shutdown function */
PHP_MINFO(xml), /* information function */
NO_VERSION_YET,
- STANDARD_MODULE_PROPERTIES
+ PHP_MODULE_GLOBALS(xml), /* globals descriptor */
+ PHP_GINIT(xml), /* globals ctor */
+ NULL, /* globals dtor */
+ NULL, /* post deactivate */
+ STANDARD_MODULE_PROPERTIES_EX
};
/* All the encoding functions are set to NULL right now, since all
@@ -182,12 +183,10 @@ static int le_xml_parser;
/* }}} */
/* {{{ startup, shutdown and info functions */
-#ifdef ZTS
-static void php_xml_init_globals(php_xml_globals *xml_globals_p TSRMLS_DC)
+static PHP_GINIT_FUNCTION(xml)
{
- XML(default_encoding) = "UTF-8";
+ xml_globals->default_encoding = "UTF-8";
}
-#endif
static void *php_xml_malloc_wrapper(size_t sz)
{
@@ -210,12 +209,6 @@ PHP_MINIT_FUNCTION(xml)
{
le_xml_parser = zend_register_list_destructors_ex(xml_parser_dtor, NULL, "xml", module_number);
-#ifdef ZTS
- ts_allocate_id(&xml_globals_id, sizeof(php_xml_globals), (ts_allocate_ctor) php_xml_init_globals, NULL);
-#else
- XML(default_encoding) = "UTF-8";
-#endif
-
REGISTER_LONG_CONSTANT("XML_ERROR_NONE", XML_ERROR_NONE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_NO_MEMORY", XML_ERROR_NO_MEMORY, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_SYNTAX", XML_ERROR_SYNTAX, CONST_CS|CONST_PERSISTENT);