Merge pull request #496 from lioncash/master

Memory leak cleanup. Fixing some small things that were fixed in the Dolphin source, but didn't make it over here.
This commit is contained in:
Henrik Rydgård committed 2013-01-25 11:17:21 -08:00
commit 67f849a442
5 files changed
+38 -15

No files matched your search

+6
View File
@@ -44,6 +44,8 @@ char *GetCPUString()
// INFO_LOG(BOOT, "CPU: %s", cpu_string);
break;
}
fclose(fp);
return cpu_string;
}
bool CheckCPUFeature(const char *feature)
@@ -69,6 +71,8 @@ bool CheckCPUFeature(const char *feature)
token = strtok(NULL, " ");
}
}
fclose(fp);
return false;
}
#endif
@@ -94,6 +98,8 @@ int GetCoreCount()
continue;
++cores;
}
fclose(fp);
return cores;
#endif
}
+12
View File
@@ -567,12 +567,24 @@ bool DeleteDirRecursively(const std::string &directory)
if (IsDirectory(newPath))
{
if (!DeleteDirRecursively(newPath))
{
#ifndef _WIN32
closedir(dirp);
#endif
return false;
}
}
else
{
if (!File::Delete(newPath))
{
#ifndef _WIN32
closedir(dirp);
#endif
return false;
}
}
#ifdef _WIN32
+4 -1
View File
@@ -318,9 +318,12 @@ public:
mutex_type* release()
{
return mutex();
mutex_type* const ret = mutex();
pm = NULL;
owns = false;
return ret;
}
bool owns_lock() const
+11 -7
View File
@@ -42,16 +42,20 @@ static inline int vasprintf(char **rResult, const char *aFormat, va_list aAp)
rVal = vsnprintf(result, 16, aFormat, ap);
va_end(ap);
if (rVal == -1) return rVal;
if (rVal == -1)
{
free(result);
return rVal;
}
else if (rVal >= 16)
{
free(result);
result = (char *) malloc(rVal + 1);
if (result == NULL) return -1;
free(result);
result = (char *) malloc(rVal + 1);
if (result == NULL) return -1;
va_copy(ap, aAp);
rVal = vsnprintf(result, rVal + 1, aFormat, aAp);
va_end(ap);
va_copy(ap, aAp);
rVal = vsnprintf(result, rVal + 1, aFormat, aAp);
va_end(ap);
}
*rResult = result;
+5 -7
View File
@@ -299,29 +299,27 @@ void ArmJitBlockCache::LinkBlock(int i)
{
LinkBlockExits(i);
ArmJitBlock &b = blocks[i];
std::map<u32, int>::iterator iter;
pair<multimap<u32, int>::iterator, multimap<u32, int>::iterator> ppp;
// equal_range(b) returns pair<iterator,iterator> representing the range
// of element with key b
ppp = links_to.equal_range(b.originalAddress);
if (ppp.first == ppp.second)
return;
for (multimap<u32, int>::iterator iter2 = ppp.first; iter2 != ppp.second; ++iter2) {
for (multimap<u32, int>::iterator iter = ppp.first; iter != ppp.second; ++iter) {
// PanicAlert("Linking block %i to block %i", iter2->second, i);
LinkBlockExits(iter2->second);
LinkBlockExits(iter->second);
}
}
void ArmJitBlockCache::UnlinkBlock(int i)
{
ArmJitBlock &b = blocks[i];
std::map<u32, int>::iterator iter;
pair<multimap<u32, int>::iterator, multimap<u32, int>::iterator> ppp;
ppp = links_to.equal_range(b.originalAddress);
if (ppp.first == ppp.second)
return;
for (multimap<u32, int>::iterator iter2 = ppp.first; iter2 != ppp.second; ++iter2) {
ArmJitBlock &sourceBlock = blocks[iter2->second];
for (multimap<u32, int>::iterator iter = ppp.first; iter != ppp.second; ++iter) {
ArmJitBlock &sourceBlock = blocks[iter->second];
for (int e = 0; e < 2; e++)
{
if (sourceBlock.exitAddress[e] == b.originalAddress)
@@ -368,7 +366,7 @@ void ArmJitBlockCache::InvalidateICache(u32 address, const u32 length)
// destroy JIT blocks
// !! this works correctly under assumption that any two overlapping blocks end at the same address
std::map<pair<u32,u32>, u32>::iterator it1 = block_map.lower_bound(std::make_pair(pAddr, 0)), it2 = it1, it;
std::map<pair<u32,u32>, u32>::iterator it1 = block_map.lower_bound(std::make_pair(pAddr, 0)), it2 = it1;
while (it2 != block_map.end() && it2->first.second < pAddr + length)
{
DestroyBlock(it2->second, true);