Fix: Address a few benign memory leaks
This patch is the result of static analysis identifying a number of memory leaks. The leaks are all benign as they are a result of not deallocating memory in the desctructor. The fix still has value as it removes false positives in the static analysis.
This commit is contained in:
parent
92eaac0711
commit
ff5718f042
18 changed files with 59 additions and 2 deletions
|
@ -56,6 +56,8 @@ HexFile::HexFile(const string _filename)
|
|||
|
||||
HexFile::~HexFile()
|
||||
{
|
||||
if (fp != NULL)
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -46,6 +46,11 @@ ActivityRecorder::ActivityRecorder(const string &name, int num_stages,
|
|||
std::memset(stageActive, 0, numStages);
|
||||
}
|
||||
|
||||
ActivityRecorder::~ActivityRecorder()
|
||||
{
|
||||
delete[] stageActive;
|
||||
}
|
||||
|
||||
void
|
||||
ActivityRecorder::activity()
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ class ActivityRecorder
|
|||
public:
|
||||
ActivityRecorder(const std::string &name, int num_stages,
|
||||
int longest_latency, int count);
|
||||
~ActivityRecorder();
|
||||
|
||||
/** Records that there is activity this cycle. */
|
||||
void activity();
|
||||
|
|
|
@ -243,6 +243,9 @@ BaseCPU::enableFunctionTrace()
|
|||
|
||||
BaseCPU::~BaseCPU()
|
||||
{
|
||||
delete profileEvent;
|
||||
delete[] comLoadEventQueue;
|
||||
delete[] comInstEventQueue;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -75,6 +75,11 @@ class PhysRegFile
|
|||
PhysRegFile(O3CPU *_cpu, unsigned _numPhysicalIntRegs,
|
||||
unsigned _numPhysicalFloatRegs);
|
||||
|
||||
/**
|
||||
* Destructor to free resources
|
||||
*/
|
||||
~PhysRegFile();
|
||||
|
||||
//Everything below should be pretty well identical to the normal
|
||||
//register file that exists within AlphaISA class.
|
||||
//The duplication is unfortunate but it's better than having
|
||||
|
@ -197,4 +202,11 @@ PhysRegFile<Impl>::PhysRegFile(O3CPU *_cpu, unsigned _numPhysicalIntRegs,
|
|||
memset(floatRegFile, 0, sizeof(PhysFloatReg) * numPhysicalFloatRegs);
|
||||
}
|
||||
|
||||
template <class Impl>
|
||||
PhysRegFile<Impl>::~PhysRegFile()
|
||||
{
|
||||
delete intRegFile;
|
||||
delete floatRegFile;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -84,6 +84,11 @@ Pl111::Pl111(const Params *p)
|
|||
vncserver->setFramebufferAddr(dmaBuffer);
|
||||
}
|
||||
|
||||
Pl111::~Pl111()
|
||||
{
|
||||
delete[] dmaBuffer;
|
||||
}
|
||||
|
||||
// read registers and frame buffer
|
||||
Tick
|
||||
Pl111::read(PacketPtr pkt)
|
||||
|
|
|
@ -316,6 +316,7 @@ class Pl111: public AmbaDmaDevice
|
|||
return dynamic_cast<const Params *>(_params);
|
||||
}
|
||||
Pl111(const Params *p);
|
||||
~Pl111();
|
||||
|
||||
virtual Tick read(PacketPtr pkt);
|
||||
virtual Tick write(PacketPtr pkt);
|
||||
|
|
|
@ -147,6 +147,7 @@ EtherTap::~EtherTap()
|
|||
if (buffer)
|
||||
delete [] buffer;
|
||||
|
||||
delete interface;
|
||||
delete listener;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,6 +122,11 @@ IGbE::IGbE(const Params *p)
|
|||
txFifo.clear();
|
||||
}
|
||||
|
||||
IGbE::~IGbE()
|
||||
{
|
||||
delete etherInt;
|
||||
}
|
||||
|
||||
void
|
||||
IGbE::init()
|
||||
{
|
||||
|
@ -827,6 +832,8 @@ template<class T>
|
|||
IGbE::DescCache<T>::~DescCache()
|
||||
{
|
||||
reset();
|
||||
delete[] fetchBuf;
|
||||
delete[] wbBuf;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
|
|
@ -518,7 +518,7 @@ class IGbE : public EtherDevice
|
|||
}
|
||||
|
||||
IGbE(const Params *params);
|
||||
~IGbE() {}
|
||||
~IGbE();
|
||||
virtual void init();
|
||||
|
||||
virtual EtherInt *getEthPort(const std::string &if_name, int idx);
|
||||
|
|
|
@ -135,7 +135,9 @@ NSGigE::NSGigE(Params *p)
|
|||
}
|
||||
|
||||
NSGigE::~NSGigE()
|
||||
{}
|
||||
{
|
||||
delete interface;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is to write to the PCI general configuration registers
|
||||
|
|
2
src/mem/cache/mshr.cc
vendored
2
src/mem/cache/mshr.cc
vendored
|
@ -460,4 +460,6 @@ MSHR::print(std::ostream &os, int verbosity, const std::string &prefix) const
|
|||
|
||||
MSHR::~MSHR()
|
||||
{
|
||||
delete[] targets;
|
||||
delete[] deferredTargets;
|
||||
}
|
||||
|
|
8
src/mem/cache/tags/fa_lru.cc
vendored
8
src/mem/cache/tags/fa_lru.cc
vendored
|
@ -98,6 +98,14 @@ FALRU::FALRU(unsigned _blkSize, unsigned _size, unsigned hit_latency)
|
|||
//assert(check());
|
||||
}
|
||||
|
||||
FALRU::~FALRU()
|
||||
{
|
||||
if (numCaches)
|
||||
delete[] cacheBoundaries;
|
||||
|
||||
delete[] blks;
|
||||
}
|
||||
|
||||
void
|
||||
FALRU::regStats(const string &name)
|
||||
{
|
||||
|
|
1
src/mem/cache/tags/fa_lru.hh
vendored
1
src/mem/cache/tags/fa_lru.hh
vendored
|
@ -156,6 +156,7 @@ public:
|
|||
* @param hit_latency The hit latency of the cache.
|
||||
*/
|
||||
FALRU(unsigned blkSize, unsigned size, unsigned hit_latency);
|
||||
~FALRU();
|
||||
|
||||
/**
|
||||
* Register the stats for this object.
|
||||
|
|
1
src/mem/cache/tags/iic.cc
vendored
1
src/mem/cache/tags/iic.cc
vendored
|
@ -160,6 +160,7 @@ IIC::~IIC()
|
|||
delete [] dataStore;
|
||||
delete [] tagStore;
|
||||
delete [] sets;
|
||||
delete [] dataBlks;
|
||||
}
|
||||
|
||||
/* register cache stats */
|
||||
|
|
|
@ -228,6 +228,7 @@ PageTable::unserialize(Checkpoint *cp, const std::string §ion)
|
|||
entry = new TheISA::TlbEntry();
|
||||
entry->unserialize(cp, csprintf("%s.Entry%d", name(), i));
|
||||
pTable[vaddr] = *entry;
|
||||
delete entry;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -613,6 +613,10 @@ Checkpoint::Checkpoint(const string &cpt_dir)
|
|||
}
|
||||
}
|
||||
|
||||
Checkpoint::~Checkpoint()
|
||||
{
|
||||
delete db;
|
||||
}
|
||||
|
||||
bool
|
||||
Checkpoint::find(const string §ion, const string &entry, string &value)
|
||||
|
|
|
@ -254,6 +254,7 @@ class Checkpoint
|
|||
|
||||
public:
|
||||
Checkpoint(const std::string &cpt_dir);
|
||||
~Checkpoint();
|
||||
|
||||
const std::string cptDir;
|
||||
|
||||
|
|
Loading…
Reference in a new issue