Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e56f3c96 authored by Glenn Kasten's avatar Glenn Kasten Committed by Gerrit Code Review
Browse files

Merge "strtok stores its values in thread local storage. So it can not...

Merge "strtok stores its values in thread local storage. So it can not guarantee works well when multithread environment. AudioFlinger has multithread. so strtok_r is more safe."
parents d6ca2e8b ff7455c0
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -37,9 +37,10 @@ AudioParameter::AudioParameter(const String8& keyValuePairs)
{
    char *str = new char[keyValuePairs.length()+1];
    mKeyValuePairs = keyValuePairs;
    char *last;

    strcpy(str, keyValuePairs.string());
    char *pair = strtok(str, ";");
    char *pair = strtok_r(str, ";", &last);
    while (pair != NULL) {
        if (strlen(pair) != 0) {
            size_t eqIdx = strcspn(pair, "=");
@@ -58,7 +59,7 @@ AudioParameter::AudioParameter(const String8& keyValuePairs)
        } else {
            ALOGV("AudioParameter() cstor empty key value pair");
        }
        pair = strtok(NULL, ";");
        pair = strtok_r(NULL, ";", &last);
    }

    delete[] str;