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

@ -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;
}