Ruby System, Cache Recorder: Use delete [] for trace vars
authorJoel Hestness <jthestness@gmail.com>
Mon, 8 Apr 2013 01:31:15 +0000 (20:31 -0500)
committerJoel Hestness <jthestness@gmail.com>
Mon, 8 Apr 2013 01:31:15 +0000 (20:31 -0500)
The cache trace variables are array allocated uint8_t* in the RubySystem and
the Ruby CacheRecorder, but the code used delete to free the memory, resulting
in Valgrind memory errors. Change these deletes to delete [] to get rid of the
errors.

src/mem/ruby/recorder/CacheRecorder.cc
src/mem/ruby/system/System.cc

index c5593d945c909dc9cc7e317d8a1a4face5271f7f..1e029b4004df7bdf173e73d3602c61aa9fefc007 100644 (file)
@@ -61,7 +61,7 @@ CacheRecorder::CacheRecorder(uint8_t* uncompressed_trace,
 CacheRecorder::~CacheRecorder()
 {
     if (m_uncompressed_trace != NULL) {
-        delete m_uncompressed_trace;
+        delete [] m_uncompressed_trace;
         m_uncompressed_trace = NULL;
     }
     m_seq_map.clear();
index 0e52df2ecec8eb678b285c49bd18344799fa9cba..617788b9968dff368d03f0f0b98da6d7d82e5619 100644 (file)
@@ -331,7 +331,7 @@ RubySystem::unserialize(Checkpoint *cp, const string &section)
                             memory_trace_size);
         m_mem_vec_ptr->populatePages(uncompressed_trace);
 
-        delete uncompressed_trace;
+        delete [] uncompressed_trace;
         uncompressed_trace = NULL;
     }