diff options
author | jshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 15:42:49 +0000 |
---|---|---|
committer | jshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 15:42:49 +0000 |
commit | 9b4453dca53380e88547252741fa907b30e01d28 (patch) | |
tree | 8e88c57b3d842d4c4664fb8b331449705548f81f /media | |
parent | 55223fa27486035436f589974f921135da2841fa (diff) | |
download | chromium_src-9b4453dca53380e88547252741fa907b30e01d28.zip chromium_src-9b4453dca53380e88547252741fa907b30e01d28.tar.gz chromium_src-9b4453dca53380e88547252741fa907b30e01d28.tar.bz2 |
Fix memory leask in media yuv_convert unit tests. Replace pointers init'd by plain new[] with scoped_array.
BUG=20497 (http://crbug.com/20497)
TEST=Valgrind does not report memory leaks any more in media/base/yuv_convert_unittest.cc
Review URL: http://codereview.chromium.org/182010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24735 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/yuv_convert_unittest.cc | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/media/base/yuv_convert_unittest.cc b/media/base/yuv_convert_unittest.cc index d647136..d1d7672 100644 --- a/media/base/yuv_convert_unittest.cc +++ b/media/base/yuv_convert_unittest.cc @@ -139,20 +139,20 @@ TEST(YuvScaleTest, YV12) { .Append(FILE_PATH_LITERAL("data")) .Append(FILE_PATH_LITERAL("bali.yv12.640_360.yuv")); const size_t size_of_yuv = kWidth * kHeight * 12 / 8; // 12 bpp. - uint8* yuv_bytes = new uint8[size_of_yuv]; + scoped_array<uint8> yuv_bytes(new uint8[size_of_yuv]); EXPECT_EQ(static_cast<int>(size_of_yuv), file_util::ReadFile(yuv_url, - reinterpret_cast<char*>(yuv_bytes), + reinterpret_cast<char*>(yuv_bytes.get()), static_cast<int>(size_of_yuv))); // Scale a frame of YUV to 32 bit ARGB. const size_t size_of_rgb_scaled = kScaledWidth * kScaledHeight * kBpp; - uint8* rgb_scaled_bytes = new uint8[size_of_rgb_scaled]; + scoped_array<uint8> rgb_scaled_bytes(new uint8[size_of_rgb_scaled]); - media::ScaleYUVToRGB32(yuv_bytes, // Y plane - yuv_bytes + kWidth * kHeight, // U plane - yuv_bytes + kWidth * kHeight * 5 / 4, // V plane - rgb_scaled_bytes, // Rgb output + media::ScaleYUVToRGB32(yuv_bytes.get(), // Y + yuv_bytes.get() + kWidth * kHeight, // U + yuv_bytes.get() + kWidth * kHeight * 5 / 4, // V + rgb_scaled_bytes.get(), // Rgb output kWidth, kHeight, // Dimensions kScaledWidth, kScaledHeight, // Dimensions kWidth, // YStride @@ -161,7 +161,7 @@ TEST(YuvScaleTest, YV12) { media::YV12, media::ROTATE_0); - unsigned int rgb_hash = hash(rgb_scaled_bytes, size_of_rgb_scaled); + unsigned int rgb_hash = hash(rgb_scaled_bytes.get(), size_of_rgb_scaled); // To get this hash value, run once and examine the following EXPECT_EQ. // Then plug new hash value into EXPECT_EQ statements. @@ -183,29 +183,29 @@ TEST(YuvScaleTest, YV16) { .Append(FILE_PATH_LITERAL("data")) .Append(FILE_PATH_LITERAL("bali.yv16.640_360.yuv")); const size_t size_of_yuv = kWidth * kHeight * 16 / 8; // 16 bpp. - uint8* yuv_bytes = new uint8[size_of_yuv]; + scoped_array<uint8> yuv_bytes(new uint8[size_of_yuv]); EXPECT_EQ(static_cast<int>(size_of_yuv), file_util::ReadFile(yuv_url, - reinterpret_cast<char*>(yuv_bytes), + reinterpret_cast<char*>(yuv_bytes.get()), static_cast<int>(size_of_yuv))); // Scale a frame of YUV to 32 bit ARGB. const size_t size_of_rgb_scaled = kScaledWidth * kScaledHeight * kBpp; - uint8* rgb_scaled_bytes = new uint8[size_of_rgb_scaled]; - - media::ScaleYUVToRGB32(yuv_bytes, // Y plane - yuv_bytes + kWidth * kHeight, // U plane - yuv_bytes + kWidth * kHeight * 3 / 2, // V plane - rgb_scaled_bytes, // Rgb output - kWidth, kHeight, // Dimensions - kScaledWidth, kScaledHeight, // Dimensions - kWidth, // YStride - kWidth / 2, // UvStride - kScaledWidth * kBpp, // RgbStride + scoped_array<uint8> rgb_scaled_bytes(new uint8[size_of_rgb_scaled]); + + media::ScaleYUVToRGB32(yuv_bytes.get(), // Y + yuv_bytes.get() + kWidth * kHeight, // U + yuv_bytes.get() + kWidth * kHeight * 3 / 2, // V + rgb_scaled_bytes.get(), // Rgb output + kWidth, kHeight, // Dimensions + kScaledWidth, kScaledHeight, // Dimensions + kWidth, // YStride + kWidth / 2, // UvStride + kScaledWidth * kBpp, // RgbStride media::YV16, media::ROTATE_0); - unsigned int rgb_hash = hash(rgb_scaled_bytes, size_of_rgb_scaled); + unsigned int rgb_hash = hash(rgb_scaled_bytes.get(), size_of_rgb_scaled); // To get this hash value, run once and examine the following EXPECT_EQ. // Then plug new hash value into EXPECT_EQ statements. |