summaryrefslogtreecommitdiffstats
path: root/components/copresence
diff options
context:
space:
mode:
authorckehoe <ckehoe@chromium.org>2015-02-04 22:35:51 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-05 06:37:13 +0000
commitd4a7555d48010a9971defa89f6b1b5a5ff545c70 (patch)
tree1e91374edf0c870a92d49f58e7ecfab8314eccde /components/copresence
parent94ae1f37922badae0012395018c23342f33d13b7 (diff)
downloadchromium_src-d4a7555d48010a9971defa89f6b1b5a5ff545c70.zip
chromium_src-d4a7555d48010a9971defa89f6b1b5a5ff545c70.tar.gz
chromium_src-d4a7555d48010a9971defa89f6b1b5a5ff545c70.tar.bz2
Fixing rand_r memory error
TBR=rkc@chromium.org Review URL: https://codereview.chromium.org/902493004 Cr-Commit-Position: refs/heads/master@{#314768}
Diffstat (limited to 'components/copresence')
-rw-r--r--components/copresence/test/audio_test_support.cc7
-rw-r--r--components/copresence/test/audio_test_support.h2
2 files changed, 4 insertions, 5 deletions
diff --git a/components/copresence/test/audio_test_support.cc b/components/copresence/test/audio_test_support.cc
index ef916eb..5dd8966 100644
--- a/components/copresence/test/audio_test_support.cc
+++ b/components/copresence/test/audio_test_support.cc
@@ -10,15 +10,14 @@
namespace copresence {
-void PopulateSamples(int random_seed, size_t size, float* samples) {
- srand(random_seed);
+void PopulateSamples(unsigned int random_seed, size_t size, float* samples) {
#if defined(OS_WIN)
+ srand(random_seed);
for (size_t i = 0; i < size; ++i)
samples[i] = (2.0 * rand() / RAND_MAX) - 1;
#else
- unsigned int rand_state;
for (size_t i = 0; i < size; ++i)
- samples[i] = (2.0 * rand_r(&rand_state) / RAND_MAX) - 1;
+ samples[i] = (2.0 * rand_r(&random_seed) / RAND_MAX) - 1;
#endif
}
diff --git a/components/copresence/test/audio_test_support.h b/components/copresence/test/audio_test_support.h
index 205577b..baae22d 100644
--- a/components/copresence/test/audio_test_support.h
+++ b/components/copresence/test/audio_test_support.h
@@ -18,7 +18,7 @@ class AudioBusRefCounted;
namespace copresence {
// Populate random samples given a random seed into the samples array.
-void PopulateSamples(int random_seed, size_t size, float* samples);
+void PopulateSamples(unsigned int random_seed, size_t size, float* samples);
// Create an ref counted audio bus populated with random samples.
scoped_refptr<media::AudioBusRefCounted>