serial_cli: use the reentrant version of strtok().

Newlib's strtok() allocates memory and causes malloc() to be linked
in.  Use the reentrant version instead.

Saves 336 bytes.

Signed-off-by: Michael Hope <mlhx@google.com>
This commit is contained in:
Michael Hope 2015-05-20 05:33:15 +02:00 committed by Dominic Clifton
parent 48024e512e
commit 3740779912
1 changed files with 3 additions and 2 deletions

View File

@ -1363,13 +1363,14 @@ static void cliMotor(char *cmdline)
int motor_value = 0; int motor_value = 0;
int index = 0; int index = 0;
char *pch = NULL; char *pch = NULL;
char *saveptr;
if (isEmpty(cmdline)) { if (isEmpty(cmdline)) {
cliPrint("Usage:\r\nmotor index [value] - show [or set] motor value\r\n"); cliPrint("Usage:\r\nmotor index [value] - show [or set] motor value\r\n");
return; return;
} }
pch = strtok(cmdline, " "); pch = strtok_r(cmdline, " ", &saveptr);
while (pch != NULL) { while (pch != NULL) {
switch (index) { switch (index) {
case 0: case 0:
@ -1380,7 +1381,7 @@ static void cliMotor(char *cmdline)
break; break;
} }
index++; index++;
pch = strtok(NULL, " "); pch = strtok_r(NULL, " ", &saveptr);
} }
if (motor_index < 0 || motor_index >= MAX_SUPPORTED_MOTORS) { if (motor_index < 0 || motor_index >= MAX_SUPPORTED_MOTORS) {