summaryrefslogtreecommitdiff
path: root/src/extension.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/extension.cpp')
-rw-r--r--src/extension.cpp60
1 files changed, 29 insertions, 31 deletions
diff --git a/src/extension.cpp b/src/extension.cpp
index ee22794..2ed4fa7 100644
--- a/src/extension.cpp
+++ b/src/extension.cpp
@@ -65,11 +65,6 @@ static ZEND_DECLARE_MODULE_GLOBALS(phpcpp)
*/
static void php_phpcpp_init_globals(zend_phpcpp_globals *globals) {}
-/**
- * The extension is a sort of singleton, so we keep one pointer to it here
- * @var Extension
- */
-static Extension *extension = nullptr;
/**
@@ -149,37 +144,40 @@ static int request_shutdown(INIT_FUNC_ARGS)
*/
Extension::Extension(const char *name, const char *version, const Functions &functions)
{
+ // allocate memory
+ _entry = new zend_module_entry;
+
// assign all members (apart from the globals)
- _entry.size = sizeof(zend_module_entry); // size of the data
- _entry.zend_api = ZEND_MODULE_API_NO; // api number
- _entry.zend_debug = ZEND_DEBUG; // debug mode enabled?
- _entry.zts = USING_ZTS; // is thread safety enabled?
- _entry.ini_entry = NULL; // the php.ini record
- _entry.deps = NULL; // dependencies on other modules
- _entry.name = HiddenPointer<Extension>(this, name); // extension name, with a hidden pointer to the extension object
- _entry.functions = functions.internal(); // functions supported by this module
- _entry.module_startup_func = extension_startup; // startup function for the whole extension
- _entry.module_shutdown_func = extension_shutdown; // shutdown function for the whole extension
- _entry.request_startup_func = request_startup; // startup function per request
- _entry.request_shutdown_func = request_shutdown; // shutdown function per request
- _entry.info_func = NULL; // information for retrieving info
- _entry.version = version; // version string
- _entry.globals_size = 0; // size of the global variables
- _entry.globals_ptr = NULL; // pointer to the globals
- _entry.globals_ctor = NULL; // constructor for global variables
- _entry.globals_dtor = NULL; // destructor for global variables
- _entry.post_deactivate_func = NULL; // unknown function
- _entry.module_started = 0; // module is not yet started
- _entry.type = 0; // temporary or persistent module, will be filled by Zend engine
- _entry.handle = NULL; // dlopen() handle, will be filled by Zend engine
- _entry.module_number = 0; // module number will be filled in by Zend engine
- _entry.build_id = ZEND_MODULE_BUILD_ID; // check if extension and zend engine are compatible
+ _entry->size = sizeof(zend_module_entry); // size of the data
+ _entry->zend_api = ZEND_MODULE_API_NO; // api number
+ _entry->zend_debug = ZEND_DEBUG; // debug mode enabled?
+ _entry->zts = USING_ZTS; // is thread safety enabled?
+ _entry->ini_entry = NULL; // the php.ini record
+ _entry->deps = NULL; // dependencies on other modules
+ _entry->name = HiddenPointer<Extension>(this, name); // extension name, with a hidden pointer to the extension object
+ _entry->functions = functions.internal(); // functions supported by this module
+ _entry->module_startup_func = extension_startup; // startup function for the whole extension
+ _entry->module_shutdown_func = extension_shutdown; // shutdown function for the whole extension
+ _entry->request_startup_func = request_startup; // startup function per request
+ _entry->request_shutdown_func = request_shutdown; // shutdown function per request
+ _entry->info_func = NULL; // information for retrieving info
+ _entry->version = version; // version string
+ _entry->globals_size = 0; // size of the global variables
+ _entry->globals_ptr = NULL; // pointer to the globals
+ _entry->globals_ctor = NULL; // constructor for global variables
+ _entry->globals_dtor = NULL; // destructor for global variables
+ _entry->post_deactivate_func = NULL; // unknown function
+ _entry->module_started = 0; // module is not yet started
+ _entry->type = 0; // temporary or persistent module, will be filled by Zend engine
+ _entry->handle = NULL; // dlopen() handle, will be filled by Zend engine
+ _entry->module_number = 0; // module number will be filled in by Zend engine
+ _entry->build_id = ZEND_MODULE_BUILD_ID; // check if extension and zend engine are compatible
// things that only need to be initialized
#ifdef ZTS
- _entry.globals_id_ptr = NULL;
+ _entry->globals_id_ptr = NULL;
#else
- _entry.globals_ptr = NULL;
+ _entry->globals_ptr = NULL;
#endif
}