Convert strtok() to strtok_r() for improved thread safety.

This commit is contained in:
Micke Prag 2012-06-19 14:13:18 +02:00
parent d2332cb605
commit c26efc1305

View file

@ -45,14 +45,15 @@ std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Co
strcpy(tempUnits, strUnits.c_str());
#endif
char *strToken = strtok(tempUnits, ",");
char *saveptr;
char *strToken = strtok_r(tempUnits, ",", &saveptr);
do {
int intUnit = atoi(strToken);
if (intUnit == 10) {
intUnit = 0;
}
intUnits = intUnits | ( 1<<(9-intUnit) );
} while ( (strToken = strtok(NULL, ",")) != NULL );
} while ( (strToken = strtok_r(NULL, ",", &saveptr)) != NULL );
delete[] tempUnits;