com php-src: cleanup: phpdbg_cmd.c phpdbg_prompt.c
| From: | Bob Weinand | Date: | Tue, 19 Nov 2013 19:24:21 +0000 |
| Subject: | com php-src: cleanup: phpdbg_cmd.c phpdbg_prompt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74795@lists.php.net to get a copy of this message | ||
Commit: cfc62cdbe00d78e17b5289c10249c82a0f35a095
Author: krakjoe <joe.watkins@live.co.uk> Tue, 19 Nov 2013 19:24:21 +0000
Parents: 13b0ef71b5b7f5770849c8396f00e31ba4f8d50f
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cfc62cdbe00d78e17b5289c10249c82a0f35a095
Log:
cleanup
Changed paths:
M phpdbg_cmd.c
M phpdbg_prompt.c
Diff:
diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c
index b181b34..765999b 100644
--- a/phpdbg_cmd.c
+++ b/phpdbg_cmd.c
@@ -123,8 +123,8 @@ static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc TSRMLS_D
char *p, *s;
char b[PHPDBG_MAX_CMD];
int l=0;
- enum states {
- IN_BETWEEN,
+ enum states {
+ IN_BETWEEN,
IN_WORD,
IN_STRING
} state = IN_BETWEEN;
@@ -134,11 +134,14 @@ static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc
TSRMLS_D
(*argc) = 0;
#define RESET_STATE() do {\
- phpdbg_input_t *next = emalloc(sizeof(phpdbg_input_t));\
- if (next) {\
+ phpdbg_input_t *arg = emalloc(sizeof(phpdbg_input_t));\
+ if (arg) {\
b[l]=0;\
- next->string = estrndup(b, l);\
- argv[(*argc)++] = next;\
+ arg->string = estrndup(b, l);\
+ arg->argv=NULL;\
+ arg->argc=0;\
+ argv = (phpdbg_input_t**) erealloc(argv, sizeof(phpdbg_input_t*) * ((*argc)+1));\
+ argv[(*argc)++] = arg;\
l=0;\
}\
state = IN_BETWEEN;\
@@ -283,6 +286,30 @@ phpdbg_input_t* phpdbg_read_input(TSRMLS_D) /* {{{ */
return NULL;
} /* }}} */
+void phpdbg_destroy_input(phpdbg_input_t **input TSRMLS_DC) /*{{{ */
+{
+ if (*input) {
+
+ if ((*input)->string) {
+ efree((*input)->string);
+ }
+
+ if ((*input)->argc > 0) {
+ int arg;
+ for (arg=0; arg<(*input)->argc; arg++) {
+ phpdbg_destroy_input(
+ &(*input)->argv[arg] TSRMLS_CC);
+ }
+ }
+
+ if ((*input)->argv) {
+ efree((*input)->argv);
+ }
+
+ efree(*input);
+ }
+} /* }}} */
+
int phpdbg_do_cmd(const phpdbg_command_t *command, char *cmd_line, size_t cmd_len TSRMLS_DC) /* {{{
*/
{
int rc = FAILURE;
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index f84ced0..d5b4bda 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -993,11 +993,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
}
}
- if (input->string) {
- efree(input->string);
- }
- efree(input);
-
+ phpdbg_destroy_input(&input TSRMLS_CC);
} while ((input = phpdbg_read_input(TSRMLS_C)) && (input->length > 0L));
if (!input->length)
@@ -1013,12 +1009,7 @@ last:
}
out:
- if (input) {
- if (input->string) {
- efree(input->string);
- }
- efree(input);
- }
+ phpdbg_destroy_input(&input TSRMLS_CC);
return ret;
} /* }}} */