com php-src: registered functions able to accept any number of arguments: phpdbg_cmd.c phpdbg_prompt.c

From: Date: Wed, 20 Nov 2013 12:49:47 +0000
Subject: com php-src: registered functions able to accept any number of arguments: phpdbg_cmd.c phpdbg_prompt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74776@lists.php.net to get a copy of this message
Commit: cad9fb826bbbb2fa9dd6e79c8d391149714260d0 Author: krakjoe <joe.watkins@live.co.uk> Wed, 20 Nov 2013 12:49:47 +0000 Parents: 80386a329b531e4dba70a85c3e87b291e2f37c51 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cad9fb826bbbb2fa9dd6e79c8d391149714260d0 Log: registered functions able to accept any number of arguments Changed paths: M phpdbg_cmd.c M phpdbg_prompt.c Diff: diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 27470be..12dc2e3 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -130,7 +130,7 @@ phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc TSRMLS_DC) /* {{{ */ } state = IN_BETWEEN; phpdbg_input_t **argv = NULL; - argv = (phpdbg_input_t**) emalloc(sizeof(phpdbg_input_t**)); + argv = (phpdbg_input_t**) emalloc(sizeof(phpdbg_input_t*)); (*argc) = 0; #define RESET_STATE() do {\ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 0436e93..57e759a 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -917,7 +917,7 @@ static PHPDBG_COMMAND(list) /* {{{ */ return SUCCESS; } /* }}} */ -static inline int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */ +int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */ { phpdbg_input_t *function = input->argv[0]; @@ -925,53 +925,47 @@ static inline int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ * &PHPDBG_G(registered), function->string, function->length+1)) { zval fname, *fretval; - zend_fcall_info fci; + zend_fcall_info *fci = emalloc(sizeof(zend_fcall_info)); ZVAL_STRINGL(&fname, function->string, function->length, 1); - fci.size = sizeof(fci); - fci.function_table = &PHPDBG_G(registered); - fci.function_name = &fname; - fci.symbol_table = EG(active_symbol_table); - fci.object_ptr = NULL; - fci.retval_ptr_ptr = &fretval; - fci.no_separation = 1; + fci->size = sizeof(zend_fcall_info); + fci->function_table = &PHPDBG_G(registered); + fci->function_name = &fname; + fci->symbol_table = EG(active_symbol_table); + fci->object_ptr = NULL; + fci->retval_ptr_ptr = &fretval; + fci->no_separation = 1; if (input->argc > 1) { - int arg; - zval ***params; - zval *zparam; + int param; + zval params; - fci.param_count = (input->argc > 1) ? (input->argc-1) : 0; - fci.params = (zval***) emalloc(fci.param_count * sizeof(zval**)); + array_init(&params); - params = fci.params; + for (param = 0; param < (input->argc-1); param++) { + add_next_index_stringl( + &params, + input->argv[param+1]->string, + input->argv[param+1]->length, 1); - for (arg = 1; arg <= (input->argc-1); arg++) { - MAKE_STD_ZVAL(zparam); - ZVAL_STRINGL( - zparam, - input->argv[arg]->string, - input->argv[arg]->length, 1); - - *params++ = &zparam; + phpdbg_debug( + "created param[%d] from argv[%d]: %s", + param, param+1, input->argv[param+1]->string); } - } else { - fci.params = NULL; - fci.param_count = 0; - } - - zend_call_function(&fci, NULL TSRMLS_CC); - - if (input->argc > 1) { - int param; - for (param = 0; param < fci.param_count; param++) { - zval_ptr_dtor(fci.params[param]); - } - efree(fci.params); + zend_fcall_info_args(fci, &params TSRMLS_CC); + } else { + fci->params = NULL; + fci->param_count = 0; } + phpdbg_debug( + "created %d params from %d argvuments", + fci->param_count, input->argc); + + zend_call_function(fci, NULL TSRMLS_CC); + if (fretval) { zend_print_zval_r( fretval, 0 TSRMLS_CC); @@ -980,6 +974,12 @@ static inline int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ * zval_dtor(&fname); + if (fci->params) { + efree(fci->params); + } + + efree(fci); + return SUCCESS; }

« previous php.cvs (#74776) next »