mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 22:05:17 +03:00
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:
parent
48024e512e
commit
3740779912
1 changed files with 3 additions and 2 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue