X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/d0581f881c4072ef0ac453167a98dc3bc0d87d86..55027f3b53e5250768632efdd470c9e938e883e7:/avr/cli.c diff --git a/avr/cli.c b/avr/cli.c index 01ad81b..be5df40 100644 --- a/avr/cli.c +++ b/avr/cli.c @@ -181,11 +181,11 @@ static int cli_run_command(const char *cmd, int flag) if (!cmd || !*cmd) return -1; /* empty command */ - - cmdbuf = xmalloc(strlen(cmd) + 1); + cmdbuf = strdup(cmd); finaltoken = xmalloc(CONFIG_SYS_CBSIZE); + if (!finaltoken) + return -1; /* not enough memory */ - strcpy(cmdbuf, cmd); str = cmdbuf; /* Process separators and check for invalid @@ -309,11 +309,8 @@ void cli_loop(void) flag = 0; /* assume no special flags for now */ if (len > 0) { - lastcommand = (char *) xrealloc(lastcommand, len+1); - if (lastcommand != NULL) { - strncpy(lastcommand, console_buffer, len+1); - lastcommand[len] = '\0'; - } + free (lastcommand); + lastcommand = strdup(console_buffer); } else if (len == 0) flag |= CMD_FLAG_REPEAT;