diff --git a/src/Register.cpp b/src/Register.cpp index b40c59b..923a98b 100644 --- a/src/Register.cpp +++ b/src/Register.cpp @@ -24,6 +24,7 @@ // $Id$ +#include #include #include "RspProxyMain.h" @@ -45,13 +46,27 @@ using std::hex; //----------------------------------------------------------------------------- Register::Register () { - name = "Unset"; + name = NULL; size = -1; value = 0; } // Register () +//----------------------------------------------------------------------------- +//! Destructor + +//! Free up data structures +//----------------------------------------------------------------------------- +Register::~Register () +{ + if (name) + { + free (const_cast(name)); + } +} // ~Register () + + //----------------------------------------------------------------------------- //! Set the state fields of the register diff --git a/src/Register.h b/src/Register.h index 00b71fd..5d71d02 100644 --- a/src/Register.h +++ b/src/Register.h @@ -42,6 +42,7 @@ class Register // Constructor Register (); + ~Register (); // Various accessor functions void set (const char *_name, diff --git a/src/SimProc.cpp b/src/SimProc.cpp index 18ef4fd..7df15df 100644 --- a/src/SimProc.cpp +++ b/src/SimProc.cpp @@ -809,6 +809,7 @@ SimProc::parseRegister (int regNum) // Error recovery time. If we get a failure between braces, we just scan // to the end brace and return. parseError ("comma missing after name. Skipping register specification"); + free (regName); skipBrace (); return; } @@ -824,6 +825,7 @@ SimProc::parseRegister (int regNum) // Error recovery time. If we get a failure between braces, we just scan // to the end brace and return. parseError ("Register size missing. Skipping register specification"); + free (regName); skipBrace (); return; } @@ -838,6 +840,7 @@ SimProc::parseRegister (int regNum) // Error recovery time. If we get a failure between braces, we just scan // to the end brace and return. parseError ("comma missing after size. Skipping register specification"); + free (regName); skipBrace (); return; } @@ -853,6 +856,7 @@ SimProc::parseRegister (int regNum) // Error recovery time. If we get a failure between braces, we just scan // to the end brace and return. parseError ("Register value missing. Skipping register specification"); + free (regName); skipBrace (); return; } @@ -874,6 +878,7 @@ SimProc::parseRegister (int regNum) scan (); // Skip unwanted symbol } + free (regName); return; } @@ -885,6 +890,7 @@ SimProc::parseRegister (int regNum) else { parseError ("Too many registers specified: %d", regNum); + free (regName); } } // parseRegister ()