Code Cleanup
- Addressed valgrind complaints by freeing allocations for commands and columns. This leaves one complaint about getpwuid, which is either an optional free, or not valid, depending on OS. (Thanks to Bryce Harrington).
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
------ current release ---------------------------
|
||||
|
||||
2.0.1 ()
|
||||
+ Addressed valgrind complaints (thanks to Bryce Harrington).
|
||||
|
||||
------ old releases ------------------------------
|
||||
|
||||
|
||||
@@ -66,6 +66,13 @@ Context::Context ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Context::~Context ()
|
||||
{
|
||||
std::map<std::string, Command*>::iterator com;
|
||||
for (com = commands.begin (); com != commands.end (); ++com)
|
||||
delete com->second;
|
||||
|
||||
std::map<std::string, Column*>::iterator col;
|
||||
for (col = columns.begin (); col != columns.end (); ++col)
|
||||
delete col->second;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -564,6 +571,10 @@ const std::vector <std::string> Context::getCommands () const
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Context::assumeLocations ()
|
||||
{
|
||||
// Note that this pointer is deliberately not free()'d, even though valgrind
|
||||
// complains about it. It is either not necessary, or forbidden, depending
|
||||
// on OS.
|
||||
|
||||
// Set up default locations.
|
||||
struct passwd* pw = getpwuid (getuid ());
|
||||
if (!pw)
|
||||
|
||||
@@ -56,6 +56,16 @@ ViewTask::ViewTask ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ViewTask::~ViewTask ()
|
||||
{
|
||||
std::vector <Column*>::iterator i;
|
||||
for (i = _columns.begin (); i != _columns.end (); ++i)
|
||||
delete *i;
|
||||
|
||||
_columns.clear ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// |<---------- terminal width ---------->|
|
||||
//
|
||||
|
||||
@@ -39,7 +39,7 @@ class ViewTask
|
||||
{
|
||||
public:
|
||||
ViewTask ();
|
||||
~ViewTask () {}
|
||||
~ViewTask ();
|
||||
|
||||
// View specifications.
|
||||
void add (Column* column) { _columns.push_back (column); }
|
||||
|
||||
@@ -55,6 +55,16 @@ ViewText::ViewText ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ViewText::~ViewText ()
|
||||
{
|
||||
std::vector <Column*>::iterator i;
|
||||
for (i = _columns.begin (); i != _columns.end (); ++i)
|
||||
delete *i;
|
||||
|
||||
_columns.clear ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int ViewText::addRow ()
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ class ViewText
|
||||
{
|
||||
public:
|
||||
ViewText ();
|
||||
~ViewText () {}
|
||||
~ViewText ();
|
||||
|
||||
// View specifications.
|
||||
void add (Column* col) { _columns.push_back (col); }
|
||||
|
||||
Reference in New Issue
Block a user