main/main.c - php_module_startup && additional modules

php.internals

Wojtek Meler

21 years ago
Hi ! I'm writing my own sapi module and I'd like register 2 additional modules calling php_module_startup. I've noticed that it is imposible because int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint num_additional_modules) is calling php_startup_extensions(&additional_modules, num_additional_modules); which signature is int php_startup_extensions(zend_module_entry **ptr, int count) php_startup_extensions expects array of pointers, while php_module_startup gets array of structures which is not convertable to array of pointers in such way. It works only when num_additional_modules equals to 0 or 1. how about adding zend_module_entry *start_extensions[num_additional_modules]; for (i=0;i<num_additional_modules;i++) start_extensions[i]=&additional_modules[i]; and passing start_extensions instead of &additional_modules to php_startup_extensions ? pros: - works fine, - no change in method signature cons: - you have to build array of structures to pass it to php_startup_module while it is common to have single pointers to zend_module_entry structures Of course it's better to change php_module_startup interface, while it is not often used. It would be easier to create array of pointers than copying structs to single array. Any way something should be done. Regards, Wojtek

Andi Gutmans

21 years ago
Sounds like a good idea. Can you put a patch together which we can review? Andi At 01:04 PM 11/23/2004 +0100, Wojtek Meler wrote:

Wojtek Meler

21 years ago
Which option? changing php_module_startup interface to int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint num_additional_modules) or rather adding those 2 lines to php_module_startup body ? Shall I attach patch to a message or put it somewhere in the web ? Regards, Wojtek Andi Gutmans wrote:

Andi Gutmans

21 years ago
I was thinking about adding those two lines. At 07:14 AM 11/24/2004 +0100, Wojtek Meler wrote:

Wojtek Meler

21 years ago
Here you are. Andi Gutmans wrote:

Andi Gutmans

21 years ago
Hi, Please send me the diff as an attachment and change zend_module_entry *start_extensions[num_additional_modules]; to use do_alloca(), free_alloca(). I will then commit to HEAD. Thanks, Andi At 08:42 AM 12/9/2004 +0100, Wojtek Meler wrote: