mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
cleanup
This commit is contained in:
parent
13b0ef71b5
commit
cfc62cdbe0
2 changed files with 35 additions and 17 deletions
35
phpdbg_cmd.c
35
phpdbg_cmd.c
|
@ -134,11 +134,14 @@ static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *argc TSRMLS_D
|
||||||
(*argc) = 0;
|
(*argc) = 0;
|
||||||
|
|
||||||
#define RESET_STATE() do {\
|
#define RESET_STATE() do {\
|
||||||
phpdbg_input_t *next = emalloc(sizeof(phpdbg_input_t));\
|
phpdbg_input_t *arg = emalloc(sizeof(phpdbg_input_t));\
|
||||||
if (next) {\
|
if (arg) {\
|
||||||
b[l]=0;\
|
b[l]=0;\
|
||||||
next->string = estrndup(b, l);\
|
arg->string = estrndup(b, l);\
|
||||||
argv[(*argc)++] = next;\
|
arg->argv=NULL;\
|
||||||
|
arg->argc=0;\
|
||||||
|
argv = (phpdbg_input_t**) erealloc(argv, sizeof(phpdbg_input_t*) * ((*argc)+1));\
|
||||||
|
argv[(*argc)++] = arg;\
|
||||||
l=0;\
|
l=0;\
|
||||||
}\
|
}\
|
||||||
state = IN_BETWEEN;\
|
state = IN_BETWEEN;\
|
||||||
|
@ -283,6 +286,30 @@ phpdbg_input_t* phpdbg_read_input(TSRMLS_D) /* {{{ */
|
||||||
return NULL;
|
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 phpdbg_do_cmd(const phpdbg_command_t *command, char *cmd_line, size_t cmd_len TSRMLS_DC) /* {{{ */
|
||||||
{
|
{
|
||||||
int rc = FAILURE;
|
int rc = FAILURE;
|
||||||
|
|
|
@ -993,11 +993,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->string) {
|
phpdbg_destroy_input(&input TSRMLS_CC);
|
||||||
efree(input->string);
|
|
||||||
}
|
|
||||||
efree(input);
|
|
||||||
|
|
||||||
} while ((input = phpdbg_read_input(TSRMLS_C)) && (input->length > 0L));
|
} while ((input = phpdbg_read_input(TSRMLS_C)) && (input->length > 0L));
|
||||||
|
|
||||||
if (!input->length)
|
if (!input->length)
|
||||||
|
@ -1013,12 +1009,7 @@ last:
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (input) {
|
phpdbg_destroy_input(&input TSRMLS_CC);
|
||||||
if (input->string) {
|
|
||||||
efree(input->string);
|
|
||||||
}
|
|
||||||
efree(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue