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
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;