diff options
| author | Ben Fuhrmannek | 2021-09-23 12:23:40 +0200 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-09-23 12:23:40 +0200 |
| commit | 54c352c1b5aa08b187dd1e52e544709cad2b0fee (patch) | |
| tree | d15bf0f484c6baa1f2718e625e0d49f6fb488507 /src/sp_ini.c | |
| parent | 887e1c9d44fbcf5f23a928269034593b8521aaba (diff) | |
config is stack allocated now + some code improvements (see details)
* for easier memory manegement, the entire sp_config struct was merged into snuffleupagus_globals and allocated on stack where possible
* SNUFFLEUPAGUS_G() can be written as SPG(), which is faster to type and easier to read
* execution_depth is re-initialized to 0 for each request
* function calls with inline string and length parameters consistently use ZEND_STRL instead of sizeof()-1
* execution is actually hooked if recursion protection is enabled
* some line breaks were removed to make the code more readable
Diffstat (limited to 'src/sp_ini.c')
| -rw-r--r-- | src/sp_ini.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/sp_ini.c b/src/sp_ini.c index 5777ca3..2238e3a 100644 --- a/src/sp_ini.c +++ b/src/sp_ini.c | |||
| @@ -17,7 +17,7 @@ static bool /* success */ sp_ini_check(zend_string *varname, zend_string *new_va | |||
| 17 | return false; | 17 | return false; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | sp_config_ini *cfg = SNUFFLEUPAGUS_G(config).config_ini; | 20 | sp_config_ini *cfg = &(SPCFG(ini)); |
| 21 | sp_ini_entry *entry = zend_hash_find_ptr(cfg->entries, varname); | 21 | sp_ini_entry *entry = zend_hash_find_ptr(cfg->entries, varname); |
| 22 | if (sp_entry_p) { | 22 | if (sp_entry_p) { |
| 23 | *sp_entry_p = entry; | 23 | *sp_entry_p = entry; |
| @@ -92,7 +92,7 @@ static PHP_INI_MH(sp_ini_onmodify) { | |||
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | void sp_hook_ini() { | 94 | void sp_hook_ini() { |
| 95 | sp_config_ini *cfg = SNUFFLEUPAGUS_G(config).config_ini; | 95 | sp_config_ini *cfg = &(SPCFG(ini)); |
| 96 | sp_ini_entry *sp_entry; | 96 | sp_ini_entry *sp_entry; |
| 97 | zend_ini_entry *ini_entry; | 97 | zend_ini_entry *ini_entry; |
| 98 | ZEND_HASH_FOREACH_PTR(cfg->entries, sp_entry) | 98 | ZEND_HASH_FOREACH_PTR(cfg->entries, sp_entry) |
| @@ -129,7 +129,7 @@ void sp_hook_ini() { | |||
| 129 | void sp_unhook_ini() { | 129 | void sp_unhook_ini() { |
| 130 | sp_ini_entry *sp_entry; | 130 | sp_ini_entry *sp_entry; |
| 131 | zend_ini_entry *ini_entry; | 131 | zend_ini_entry *ini_entry; |
| 132 | ZEND_HASH_FOREACH_PTR(SNUFFLEUPAGUS_G(config).config_ini->entries, sp_entry) | 132 | ZEND_HASH_FOREACH_PTR(SPCFG(ini).entries, sp_entry) |
| 133 | if (!sp_entry->orig_onmodify) { | 133 | if (!sp_entry->orig_onmodify) { |
| 134 | // not hooked or no original onmodify | 134 | // not hooked or no original onmodify |
| 135 | continue; | 135 | continue; |
