From d4a7555d48010a9971defa89f6b1b5a5ff545c70 Mon Sep 17 00:00:00 2001 From: ckehoe Date: Wed, 4 Feb 2015 22:35:51 -0800 Subject: Fixing rand_r memory error TBR=rkc@chromium.org Review URL: https://codereview.chromium.org/902493004 Cr-Commit-Position: refs/heads/master@{#314768} --- components/copresence/test/audio_test_support.cc | 7 +++---- components/copresence/test/audio_test_support.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'components/copresence') 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 -- cgit v1.1