Skip to content

Commit e2e7b46

Browse files
committed
sapi/phpdbg: Grab the function pointer directly
Allocating a string zval to let zend_call_function() do the same thing is slightly pointless
1 parent a58c6d5 commit e2e7b46

File tree

1 file changed

+8
-32
lines changed

1 file changed

+8
-32
lines changed

sapi/phpdbg/phpdbg_prompt.c

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -96,34 +96,18 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */
9696
phpdbg_param_t *name = NULL;
9797

9898
if (stack->type == STACK_PARAM) {
99-
char *lc_name;
100-
10199
name = stack->next;
102100

103101
if (!name || name->type != STR_PARAM) {
104102
return FAILURE;
105103
}
106104

107-
lc_name = zend_str_tolower_dup(name->str, name->len);
108-
109-
if (zend_hash_str_exists(&PHPDBG_G(registered), lc_name, name->len)) {
110-
zval fretval;
111-
zend_fcall_info fci;
112-
113-
memset(&fci, 0, sizeof(zend_fcall_info));
114-
115-
ZVAL_STRINGL(&fci.function_name, lc_name, name->len);
116-
fci.size = sizeof(zend_fcall_info);
117-
fci.object = NULL;
118-
fci.retval = &fretval;
119-
fci.param_count = 0;
120-
fci.params = NULL;
121-
fci.named_params = NULL;
122-
123-
zval params;
105+
zend_function *user_fn = zend_hash_str_find_ptr_lc(&PHPDBG_G(registered), name->str, name->len);
106+
if (user_fn != NULL) {
107+
HashTable *params_ht = NULL;
124108
if (name->next) {
125109
phpdbg_param_t *next = name->next;
126-
110+
zval params;
127111
array_init(&params);
128112

129113
while (next) {
@@ -173,27 +157,19 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */
173157
next = next->next;
174158
}
175159
/* Add positional arguments */
176-
fci.named_params = Z_ARRVAL(params);
160+
params_ht = Z_ARRVAL(params);
161+
phpdbg_debug("created " PRIu32 " params from arguments", zend_hash_num_elements(params_ht));
177162
}
178163

179164
phpdbg_activate_err_buf(0);
180165
phpdbg_free_err_buf();
181166

182-
phpdbg_debug("created %d params from arguments", fci.param_count);
183167

184-
if (zend_call_function(&fci, NULL) == SUCCESS) {
185-
zend_print_zval_r(&fretval, 0);
186-
phpdbg_out("\n");
187-
zval_ptr_dtor(&fretval);
188-
}
189-
190-
zval_ptr_dtor_str(&fci.function_name);
191-
efree(lc_name);
168+
zend_call_known_function(user_fn, NULL, NULL, NULL, 0, NULL, params_ht);
169+
phpdbg_out("\n");
192170

193171
return SUCCESS;
194172
}
195-
196-
efree(lc_name);
197173
}
198174

199175
return FAILURE;

0 commit comments

Comments
 (0)