Convert strtok() to strtok_r() for improved thread safety.
This commit is contained in:
parent
d2332cb605
commit
c26efc1305
1 changed files with 3 additions and 2 deletions
|
@ -45,14 +45,15 @@ std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Co
|
||||||
strcpy(tempUnits, strUnits.c_str());
|
strcpy(tempUnits, strUnits.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *strToken = strtok(tempUnits, ",");
|
char *saveptr;
|
||||||
|
char *strToken = strtok_r(tempUnits, ",", &saveptr);
|
||||||
do {
|
do {
|
||||||
int intUnit = atoi(strToken);
|
int intUnit = atoi(strToken);
|
||||||
if (intUnit == 10) {
|
if (intUnit == 10) {
|
||||||
intUnit = 0;
|
intUnit = 0;
|
||||||
}
|
}
|
||||||
intUnits = intUnits | ( 1<<(9-intUnit) );
|
intUnits = intUnits | ( 1<<(9-intUnit) );
|
||||||
} while ( (strToken = strtok(NULL, ",")) != NULL );
|
} while ( (strToken = strtok_r(NULL, ",", &saveptr)) != NULL );
|
||||||
|
|
||||||
delete[] tempUnits;
|
delete[] tempUnits;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue