Fix memory leak in RewindManager (at least until it's rewritten).

This commit is contained in:
sa666666 2017-09-21 10:14:04 -02:30
parent 39267e2840
commit be64a6387d
2 changed files with 4 additions and 12 deletions

View File

@ -31,19 +31,12 @@ RewindManager::RewindManager(OSystem& system, StateManager& statemgr)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RewindManager::~RewindManager()
{
for(uInt8 i = 0; i < MAX_SIZE; ++i)
delete myStateList[i].data;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool RewindManager::addState(const string& message)
{
// Create a new Serializer object if we need one
if(myStateList[myTop].data == nullptr)
myStateList[myTop].data = new Serializer();
myStateList[myTop].data = make_unique<Serializer>();
// And use it to store the serialized data and text message
if(myStateList[myTop].data != nullptr)

View File

@ -21,6 +21,8 @@
class OSystem;
class StateManager;
#include "bspf.hxx"
/**
This class is used to save (and later 'rewind') system save states.
Essentially, it's a modified circular array-based stack that cleverly deals
@ -35,7 +37,6 @@ class RewindManager
{
public:
RewindManager(OSystem& system, StateManager& statemgr);
virtual ~RewindManager();
public:
/**
@ -63,10 +64,8 @@ class RewindManager
StateManager& myStateManager;
struct SerialData {
Serializer* data;
unique_ptr<Serializer> data;
string message;
SerialData(Serializer* d = nullptr) : data(d) { }
};
SerialData myStateList[MAX_SIZE];