trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bc...@apache.org
Subject [trafficserver] branch master updated: TS-4986: Memory leak in test_Map
Date Fri, 28 Oct 2016 00:02:26 GMT
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  6eecab0   TS-4986: Memory leak in test_Map
6eecab0 is described below

commit 6eecab0e0c993e3511c68850c8db208bad22fe42
Author: Bryan Call <bcall@apache.org>
AuthorDate: Thu Oct 27 10:35:37 2016 -0700

    TS-4986: Memory leak in test_Map
---
 lib/ts/suppression.txt |  2 ++
 lib/ts/test_Map.cc     | 16 +++++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/lib/ts/suppression.txt b/lib/ts/suppression.txt
index 30e78d9..d76f93e 100644
--- a/lib/ts/suppression.txt
+++ b/lib/ts/suppression.txt
@@ -1,2 +1,4 @@
 leak:CRYPTO_malloc
 leak:CRYPTO_realloc
+leak:ConsCell
+leak:Vec<MapElem<char const*, int>, DefaultAlloc, 2>::set_expand
diff --git a/lib/ts/test_Map.cc b/lib/ts/test_Map.cc
index 56d97da..d95990c 100644
--- a/lib/ts/test_Map.cc
+++ b/lib/ts/test_Map.cc
@@ -22,6 +22,7 @@
 */
 #include <stdint.h>
 #include "ts/Map.h"
+#include <list>
 
 typedef const char cchar;
 
@@ -67,13 +68,14 @@ test_TSHashTable()
 {
   static uint32_t const N = 270;
   Table t;
-  Item *item;
+  Item *item = nullptr;
   Table::Location loc;
+  std::list<Item *> to_delete;
 
-  item = new Item(1);
-  t.insert(item);
-  for (uint32_t i = 2; i <= N; ++i) {
-    t.insert(new Item(i));
+  for (uint32_t i = 1; i <= N; ++i) {
+    item = new Item(i);
+    t.insert(item);
+    to_delete.push_back(item);
   }
 
   for (uint32_t i = 1; i <= N; ++i) {
@@ -114,6 +116,10 @@ test_TSHashTable()
     ink_assert((spot->_value & 1) == 0);
   }
   ink_assert(n == N / 2);
+
+  for (auto it : to_delete) {
+    delete it;
+  }
 }
 
 int

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message