Commit 37407799 authored by Michael Hope's avatar Michael Hope Committed by Dominic Clifton
Browse files

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: default avatarMichael Hope <mlhx@google.com>
parent 48024e51
......@@ -1363,13 +1363,14 @@ static void cliMotor(char *cmdline)
int motor_value = 0;
int index = 0;
char *pch = NULL;
char *saveptr;
if (isEmpty(cmdline)) {
cliPrint("Usage:\r\nmotor index [value] - show [or set] motor value\r\n");
return;
}
pch = strtok(cmdline, " ");
pch = strtok_r(cmdline, " ", &saveptr);
while (pch != NULL) {
switch (index) {
case 0:
......@@ -1380,7 +1381,7 @@ static void cliMotor(char *cmdline)
break;
}
index++;
pch = strtok(NULL, " ");
pch = strtok_r(NULL, " ", &saveptr);
}
if (motor_index < 0 || motor_index >= MAX_SUPPORTED_MOTORS) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment