hg logBug 1366882 - fix resource leaks CID 1401664 1401662 1401661 r=njn
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 24 May 2017 20:09:25 +0200
changeset 410962 2ec004b70daae60449d9fb91280d170bd0178196
parent 410961 365687db6288738e30dd76d926790e1cd16df651
child 410963 4b380c4484bac968a96cf76878de0e0100d23a73
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1366882, 1401664, 1401662, 1401661
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
hg logBug 1366882 - fix resource leaks CID 1401664 1401662 1401661 r=njn MozReview-Commit-ID: FAhSIfsV2aP
tools/profiler/tests/gtest/ThreadProfileTest.cpp
--- a/tools/profiler/tests/gtest/ThreadProfileTest.cpp
+++ b/tools/profiler/tests/gtest/ThreadProfileTest.cpp
@@ -1,8 +1,9 @@
+
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gtest/gtest.h"
 
 #include "ProfileBufferEntry.h"
@@ -14,29 +15,29 @@ TEST(ThreadProfile, Initialization) {
   ThreadInfo info("testThread", tid, true, nullptr);
   info.StartProfiling();
 }
 
 // Make sure we can record one tag and read it
 TEST(ThreadProfile, InsertOneTag) {
   Thread::tid_t tid = 1000;
   ThreadInfo info("testThread", tid, true, nullptr);
-  ProfileBuffer* pb = new ProfileBuffer(10);
+  UniquePtr<ProfileBuffer> pb(new ProfileBuffer(10));
   pb->addTag(ProfileBufferEntry::Time(123.1));
   ASSERT_TRUE(pb->mEntries != nullptr);
   ASSERT_TRUE(pb->mEntries[pb->mReadPos].kind() ==
               ProfileBufferEntry::Kind::Time);
   ASSERT_TRUE(pb->mEntries[pb->mReadPos].mTagDouble == 123.1);
 }
 
 // See if we can insert some tags
 TEST(ThreadProfile, InsertTagsNoWrap) {
   Thread::tid_t tid = 1000;
   ThreadInfo info("testThread", tid, true, nullptr);
-  ProfileBuffer* pb = new ProfileBuffer(100);
+  UniquePtr<ProfileBuffer> pb(new ProfileBuffer(100));
   int test_size = 50;
   for (int i = 0; i < test_size; i++) {
     pb->addTag(ProfileBufferEntry::Time(i));
   }
   ASSERT_TRUE(pb->mEntries != nullptr);
   int readPos = pb->mReadPos;
   while (readPos != pb->mWritePos) {
     ASSERT_TRUE(pb->mEntries[readPos].kind() ==
@@ -48,17 +49,17 @@ TEST(ThreadProfile, InsertTagsNoWrap) {
 
 // See if wrapping works as it should in the basic case
 TEST(ThreadProfile, InsertTagsWrap) {
   Thread::tid_t tid = 1000;
   // we can fit only 24 tags in this buffer because of the empty slot
   int tags = 24;
   int buffer_size = tags + 1;
   ThreadInfo info("testThread", tid, true, nullptr);
-  ProfileBuffer* pb = new ProfileBuffer(buffer_size);
+  UniquePtr<ProfileBuffer> pb(new ProfileBuffer(buffer_size));
   int test_size = 43;
   for (int i = 0; i < test_size; i++) {
     pb->addTag(ProfileBufferEntry::Time(i));
   }
   ASSERT_TRUE(pb->mEntries != nullptr);
   int readPos = pb->mReadPos;
   int ctr = 0;
   while (readPos != pb->mWritePos) {