From: krakjoe Date: Mon, 18 Nov 2013 18:05:37 +0000 (+0000) Subject: no more allocing params X-Git-Tag: php-5.6.0alpha1~110^2~226 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9190e783a2cfda20c2c31463713584f5ba1b354e;p=php no more allocing params --- diff --git a/phpdbg.c b/phpdbg.c index 10067a0fda..eaa626d39a 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -39,7 +39,6 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ pg->vmret = 0; pg->bp_count = 0; pg->lcmd = NULL; - pg->lparam = NULL; pg->flags = PHPDBG_DEFAULT_FLAGS; pg->oplog = NULL; } /* }}} */ @@ -94,18 +93,6 @@ static void php_phpdbg_destroy_bp_condition(void *data) /* {{{ */ } } /* }}} */ -static void php_phpdbg_destroy_param(void *data) /* {{{ */ -{ - phpdbg_param_t *param = (phpdbg_param_t*) data; - - if (param) { - TSRMLS_FETCH(); - - phpdbg_clear_param(param TSRMLS_CC); - efree(param); - } -} /* }}} */ - static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ { zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); @@ -113,9 +100,7 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], 8, NULL, NULL, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0); - zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0); - zend_hash_init(&PHPDBG_G(params), 8, NULL, php_phpdbg_destroy_param, 0); return SUCCESS; } /* }}} */ @@ -127,9 +112,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]); zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); - zend_hash_destroy(&PHPDBG_G(seek)); - zend_hash_destroy(&PHPDBG_G(params)); if (PHPDBG_G(exec)) { efree(PHPDBG_G(exec)); diff --git a/phpdbg.h b/phpdbg.h index d88f891827..1a42d0cd85 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -115,10 +115,9 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) int bp_count; /* breakpoint count */ int vmret; /* return from last opcode handler execution */ phpdbg_command_t *lcmd; /* last command */ - phpdbg_param_t *lparam; /* last param */ + phpdbg_param_t lparam; /* last param */ FILE *oplog; /* opline log */ HashTable seek; /* seek oplines */ - HashTable params; /* parameters */ zend_ulong flags; /* phpdbg flags */ ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 1fadaa3c12..a2eb513328 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -132,36 +132,37 @@ int phpdbg_do_cmd( const phpdbg_command_t *command, char *cmd_line, size_t cmd_l if ((command->name_len == expr_len && memcmp(cmd, command->name, expr_len) == 0) || (expr_len == 1 && command->alias && command->alias == cmd_line[0])) { - param = (phpdbg_param_t*) emalloc(sizeof(phpdbg_param_t)); + phpdbg_param_t lparam, + param; phpdbg_parse_param( expr, (cmd_len - expr_len) ? (((cmd_len - expr_len) - sizeof(" "))+1) : 0, - param TSRMLS_CC); + ¶m TSRMLS_CC); + lparam = PHPDBG_G(lparam); + PHPDBG_G(lparam) = param; PHPDBG_G(lcmd) = (phpdbg_command_t*) command; - /* avoid leaks */ - zend_hash_next_index_insert( - &PHPDBG_G(params), (void**)¶m, sizeof(phpdbg_param_t*), NULL); - - if (command->subs && param->type == STR_PARAM) { - if (phpdbg_do_cmd(command->subs, param->str, param->len TSRMLS_CC) == SUCCESS) { + if (command->subs && param.type == STR_PARAM) { + if (phpdbg_do_cmd(command->subs, param.str, param.len TSRMLS_CC) == SUCCESS) { rc = SUCCESS; goto done; } } - if (command->arg_type == REQUIRED_ARG && param->type == EMPTY_PARAM) { + if (command->arg_type == REQUIRED_ARG && param.type == EMPTY_PARAM) { phpdbg_error("This command requires argument!"); rc = FAILURE; - } else if (command->arg_type == NO_ARG && param->type != EMPTY_PARAM) { + } else if (command->arg_type == NO_ARG && param.type != EMPTY_PARAM) { phpdbg_error("This command does not expect argument!"); rc = FAILURE; } else { - rc = command->handler(param TSRMLS_CC); + rc = command->handler(¶m TSRMLS_CC); } + + phpdbg_clear_param(&lparam TSRMLS_CC); break; } ++command; diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 547940fd6a..9da85da334 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -942,7 +942,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ } else { if (PHPDBG_G(lcmd)) { ret = PHPDBG_G(lcmd)->handler( - PHPDBG_G(lparam) TSRMLS_CC); + &PHPDBG_G(lparam) TSRMLS_CC); goto out; } }