Bunch of tiny memory leaks fixed and cleanup, フウ〜!

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5056 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2010-02-14 14:06:33 +00:00
parent b6aa5d91c0
commit 5b1d21d1a1
10 changed files with 61 additions and 35 deletions

View File

@ -30,7 +30,7 @@
* @file
* @brief Handles device I/O for *nix.
*/
#define BLUETOOTH_VERSION_USE_CURRENT
#include <stdio.h>
#include <stdlib.h>
@ -225,7 +225,7 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
int found_devices;
int found_wiimotes;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
IOBluetoothHostController *bth = [[IOBluetoothHostController alloc] init];
if([bth addressAsString] == nil)
@ -250,6 +250,7 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
WIIMOTE_ENABLE_STATE(wm[found_wiimotes], WIIMOTE_STATE_DEV_FOUND);
[bth release];
[bti release];
[sbt release];

View File

@ -407,7 +407,7 @@ char **cdio_get_devices() {
#elif __linux__
return cdio_get_devices_linux();
#else
// todo add somewarning
#warning CDIO not supported on your platform!
#endif
}

View File

@ -416,7 +416,14 @@ void SleepCurrentThread(int ms)
void SetCurrentThreadName(const TCHAR* szThreadName)
{
pthread_setspecific(threadname_key, strdup(szThreadName));
char *name = strdup(szThreadName);
// pthread_setspecific returns 0 on success
// free the string from strdup if fails
// creates a memory leak if it actually doesn't fail
// since we don't delete it once we delete the thread
// we are using a single threadname_key anyway for all threads
if(!pthread_setspecific(threadname_key, strdup(szThreadName)))
free(name);
INFO_LOG(COMMON, "%s(%s)\n", __FUNCTION__, szThreadName);
}

View File

@ -38,7 +38,7 @@
namespace FileMon
{
DiscIO::IVolume *OpenISO;
DiscIO::IVolume *OpenISO = NULL;
DiscIO::IFileSystem *pFileSystem = NULL;
std::vector<const DiscIO::SFileInfo *> GCFiles;
std::string ISOFile = "", CurrentFile = "";
@ -70,6 +70,18 @@ bool ShowSound(std::string FileName)
// Read the GC file system
void ReadGC(std::string FileName)
{
// Should have an actual Shutdown procedure or something
if(OpenISO != NULL)
{
delete OpenISO;
OpenISO = NULL;
}
if(pFileSystem != NULL)
{
delete pFileSystem;
pFileSystem = NULL;
}
// GCFiles' pointers are no longer valid after pFileSystem is cleared
GCFiles.clear();
OpenISO = DiscIO::CreateVolumeFromFilename(FileName);
if (!OpenISO) return;

View File

@ -37,6 +37,7 @@ CFileSystemGCWii::CFileSystemGCWii(const IVolume *_rVolume)
CFileSystemGCWii::~CFileSystemGCWii()
{
m_FileInfoVector.clear();
}
bool CFileSystemGCWii::IsInitialized() const

View File

@ -114,13 +114,17 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
LoadGameConfig();
else
{
// Will fail out if GameConfig folder doesn't exist
FILE *f = fopen(GameIniFile.c_str(), "w");
fprintf(f, "# %s - %s\n", OpenISO->GetUniqueID().c_str(), OpenISO->GetName().c_str());
fprintf(f, "[Core] Values set here will override the main dolphin settings.\n");
fprintf(f, "[EmuState] The Emulation State. 1 is worst, 5 is best, 0 is not set.\n");
fprintf(f, "[OnFrame] Add memory patches to be applied every frame here.\n");
fprintf(f, "[ActionReplay] Add action replay cheats here.\n");
fclose(f);
if (f)
{
fprintf(f, "# %s - %s\n", OpenISO->GetUniqueID().c_str(), OpenISO->GetName().c_str());
fprintf(f, "[Core] Values set here will override the main dolphin settings.\n");
fprintf(f, "[EmuState] The Emulation State. 1 is worst, 5 is best, 0 is not set.\n");
fprintf(f, "[OnFrame] Add memory patches to be applied every frame here.\n");
fprintf(f, "[ActionReplay] Add action replay cheats here.\n");
fclose(f);
}
if (GameIni.Load(GameIniFile.c_str()))
LoadGameConfig();
else
@ -203,20 +207,13 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
CISOProperties::~CISOProperties()
{
if (IsVolumeWiiDisc(OpenISO))
{
for (std::vector<WiiPartition>::const_iterator PartIter = WiiDisc.begin(); PartIter != WiiDisc.end(); ++PartIter)
{
delete PartIter->FileSystem; // Remember the FileList is a member of DiscIO::IFileSystem
delete PartIter->Partition;
}
WiiDisc.clear();
}
else
if (!IsVolumeWiiDisc(OpenISO))
if (!IsVolumeWadFile(OpenISO))
if (pFileSystem)
delete pFileSystem;
// two vector's items are no longer valid after deleting filesystem
WiiDisc.clear();
GCFiles.clear();
delete OpenGameListItem;
delete OpenISO;
}

View File

@ -177,7 +177,8 @@ void DllConfig(HWND _hParent)
if (!m_ConfigFrame)
{
m_ConfigFrame = new DSPConfigDialogHLE(GetParentedWxWindow(_hParent));
wxWindow *frame = GetParentedWxWindow(_hParent);
m_ConfigFrame = new DSPConfigDialogHLE(frame);
// add backends
std::vector<std::string> backends = AudioCommon::GetSoundBackends();
@ -192,6 +193,7 @@ void DllConfig(HWND _hParent)
m_ConfigFrame->ShowModal();
delete m_ConfigFrame;
delete frame;
m_ConfigFrame = 0;
}
#endif

View File

@ -169,10 +169,12 @@ void DllConfig(HWND _hParent)
#if defined(HAVE_WX) && HAVE_WX
if (!m_ConfigFrame)
{
m_ConfigFrame = new GCPadConfigDialog(GetParentedWxWindow(_hParent));
wxWindow *frame = GetParentedWxWindow(_hParent);
m_ConfigFrame = new GCPadConfigDialog(frame);
m_ConfigFrame->ShowModal();
m_ConfigFrame->Destroy();
m_ConfigFrame = NULL;
delete frame;
}
#endif
}

View File

@ -299,7 +299,8 @@ void DllConfig(HWND _hParent)
// Prevent user to show more than 1 config window at same time
if (allowConfigShow)
{
m_ConfigFrame = new GFXConfigDialogOGL(GetParentedWxWindow(_hParent));
wxWindow *frame = GetParentedWxWindow(_hParent);
m_ConfigFrame = new GFXConfigDialogOGL(frame);
#if defined(_WIN32)
Win32AddResolutions();
@ -314,6 +315,7 @@ void DllConfig(HWND _hParent)
allowConfigShow = m_ConfigFrame->ShowModal() == 1 ? true : false;
delete m_ConfigFrame;
delete frame;
m_ConfigFrame = 0;
}
#endif

View File

@ -183,10 +183,12 @@ void DllConfig(HWND _hParent)
#if defined(HAVE_WX) && HAVE_WX
if (!m_BasicConfigFrame)
{
m_BasicConfigFrame = new WiimoteBasicConfigDialog(GetParentedWxWindow(_hParent));
wxWindow *frame = GetParentedWxWindow(_hParent);
m_BasicConfigFrame = new WiimoteBasicConfigDialog(frame);
m_BasicConfigFrame->ShowModal();
m_BasicConfigFrame->Destroy();
m_BasicConfigFrame = NULL;
delete frame;
}
#endif
}