diff options
author | seunghak.han <seunghak.han@lge.com> | 2013-09-07 14:59:43 +0900 |
---|---|---|
committer | seunghak.han <seunghak.han@lge.com> | 2013-09-17 10:50:05 +0900 |
commit | ff7455c0c1df0c316a306fb81ee660840d08b6d0 (patch) | |
tree | 296e1aaf8779e9a6f178a2e166fe32730ce730db /media/libmedia | |
parent | fb949d5dc8a764e31fbd65bee87f59fcfeb6d848 (diff) | |
download | frameworks_av-ff7455c0c1df0c316a306fb81ee660840d08b6d0.zip frameworks_av-ff7455c0c1df0c316a306fb81ee660840d08b6d0.tar.gz frameworks_av-ff7455c0c1df0c316a306fb81ee660840d08b6d0.tar.bz2 |
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.
Change-Id: I6d77ef9cc49a4478dd856dcdca14e4920ce955c6
Diffstat (limited to 'media/libmedia')
-rw-r--r-- | media/libmedia/AudioParameter.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/media/libmedia/AudioParameter.cpp b/media/libmedia/AudioParameter.cpp index e3fea77..33dbf0b 100644 --- a/media/libmedia/AudioParameter.cpp +++ b/media/libmedia/AudioParameter.cpp @@ -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; |