Skip to content

Commit 6902734

Browse files
committed
Use zend_fcall_info_argp
1 parent 23c2c7c commit 6902734

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

ext/standard/basic_functions.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,11 +1667,7 @@ void user_shutdown_function_dtor(zval *zv) /* {{{ */
16671667
php_shutdown_function_entry *shutdown_function_entry = Z_PTR_P(zv);
16681668

16691669
zval_ptr_dtor(&shutdown_function_entry->fci.function_name);
1670-
for (size_t i = 0; i < shutdown_function_entry->fci.param_count; i++) {
1671-
zval_ptr_dtor(&shutdown_function_entry->fci.params[i]);
1672-
}
1673-
1674-
efree(shutdown_function_entry->fci.params);
1670+
zend_fcall_info_args_clear(&shutdown_function_entry->fci, true);
16751671
efree(shutdown_function_entry);
16761672
}
16771673
/* }}} */
@@ -1788,25 +1784,20 @@ PHP_FUNCTION(register_shutdown_function)
17881784
{
17891785
php_shutdown_function_entry entry;
17901786
zval *params;
1787+
uint32_t param_count;
1788+
bool status;
17911789

17921790
ZEND_PARSE_PARAMETERS_START(1, -1)
17931791
Z_PARAM_FUNC(entry.fci, entry.fci_cache)
1794-
Z_PARAM_VARIADIC('+', params, entry.fci.param_count);
1792+
Z_PARAM_VARIADIC('+', params, param_count);
17951793
ZEND_PARSE_PARAMETERS_END();
17961794

17971795
Z_TRY_ADDREF(entry.fci.function_name);
1796+
entry.fci.params = NULL;
1797+
zend_fcall_info_argp(&entry.fci, param_count, params);
17981798

1799-
if (entry.fci.param_count) {
1800-
entry.fci.params = emalloc(sizeof(zval) * entry.fci.param_count);
1801-
1802-
for (size_t i = 0; i < entry.fci.param_count; i++) {
1803-
ZVAL_COPY(&entry.fci.params[i], &params[i]);
1804-
}
1805-
} else {
1806-
entry.fci.params = NULL;
1807-
}
1808-
1809-
ZEND_ASSERT(append_user_shutdown_function(&entry));
1799+
status = append_user_shutdown_function(&entry);
1800+
ZEND_ASSERT(status);
18101801
}
18111802
/* }}} */
18121803

0 commit comments

Comments
 (0)