8198825: Resolve missing review feedback for JDK-8170976
authormlarsson
Wed, 28 Feb 2018 12:05:02 +0100
changeset 49182 bd1bfa4e563f
parent 49181 fde9b3c56de4
child 49183 268beecd832a
8198825: Resolve missing review feedback for JDK-8170976 Reviewed-by: rehn, lfoltan, hseigel
test/hotspot/gtest/logging/logTestFixture.cpp
test/hotspot/gtest/logging/logTestFixture.hpp
--- a/test/hotspot/gtest/logging/logTestFixture.cpp	Wed Feb 28 10:37:02 2018 +0100
+++ b/test/hotspot/gtest/logging/logTestFixture.cpp	Wed Feb 28 12:05:02 2018 +0100
@@ -31,7 +31,7 @@
 #include "unittest.hpp"
 #include "utilities/ostream.hpp"
 
-LogTestFixture::LogTestFixture() {
+LogTestFixture::LogTestFixture() : _configuration_snapshot(NULL), _n_snapshots(0) {
   // Set up TestLogFileName to include PID, testcase name and test name
   int ret = jio_snprintf(_filename, sizeof(_filename), "testlog.pid%d.%s.%s.log",
                          os::current_process_id(),
@@ -45,6 +45,7 @@
 
 LogTestFixture::~LogTestFixture() {
   restore_config();
+  clear_snapshot();
   delete_file(TestLogFileName);
 }
 
@@ -65,6 +66,7 @@
 }
 
 void LogTestFixture::snapshot_config() {
+  clear_snapshot();
   _n_snapshots = LogConfiguration::_n_outputs;
   _configuration_snapshot = NEW_C_HEAP_ARRAY(char*, _n_snapshots, mtLogging);
   for (size_t i = 0; i < _n_snapshots; i++) {
@@ -103,3 +105,16 @@
     set_log_config(name, selection, decorators, options != NULL ? options : "");
   }
 }
+
+void LogTestFixture::clear_snapshot() {
+  if (_configuration_snapshot == NULL) {
+    return;
+  }
+  assert(_n_snapshots > 0, "non-null array should have at least 1 element");
+  for (size_t i = 0; i < _n_snapshots; i++) {
+    os::free(_configuration_snapshot[i]);
+  }
+  FREE_C_HEAP_ARRAY(char*, _configuration_snapshot);
+  _configuration_snapshot = NULL;
+  _n_snapshots = 0;
+}
--- a/test/hotspot/gtest/logging/logTestFixture.hpp	Wed Feb 28 10:37:02 2018 +0100
+++ b/test/hotspot/gtest/logging/logTestFixture.hpp	Wed Feb 28 12:05:02 2018 +0100
@@ -49,5 +49,6 @@
 
   void snapshot_config();
   void restore_config();
+  void clear_snapshot();
 };