mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-06-06 22:54:59 -06:00
nim: Fix memory leak (#1775)
Store NIMPackage structs in vector instead of pointers on the heap
This commit is contained in:
parent
e3260daea2
commit
ca73549717
@ -40,7 +40,7 @@ namespace iosu
|
|||||||
std::vector<NIMTitleLatestVersion> titlesLatestVersion;
|
std::vector<NIMTitleLatestVersion> titlesLatestVersion;
|
||||||
// nim packages
|
// nim packages
|
||||||
// note: Seems like scope.rpx expects the number of packages to never change after the initial GetNum call?
|
// note: Seems like scope.rpx expects the number of packages to never change after the initial GetNum call?
|
||||||
std::vector<NIMPackage*> packages;
|
std::vector<NIMPackage> packages;
|
||||||
bool packageListReady;
|
bool packageListReady;
|
||||||
bool backgroundThreadStarted;
|
bool backgroundThreadStarted;
|
||||||
} g_nim = {};
|
} g_nim = {};
|
||||||
@ -139,11 +139,10 @@ namespace iosu
|
|||||||
if(latestVersionInfo->version <= (uint32)titleList[i].titleVersion )
|
if(latestVersionInfo->version <= (uint32)titleList[i].titleVersion )
|
||||||
continue; // already on latest version
|
continue; // already on latest version
|
||||||
// add to packages
|
// add to packages
|
||||||
NIMPackage* nimPackage = (NIMPackage*)malloc(sizeof(NIMPackage));
|
NIMPackage nimPackage{};
|
||||||
memset(nimPackage, 0, sizeof(NIMPackage));
|
nimPackage.titleId = titleId;
|
||||||
nimPackage->titleId = titleId;
|
nimPackage.type = PACKAGE_TYPE_UPDATE;
|
||||||
nimPackage->type = PACKAGE_TYPE_UPDATE;
|
g_nim.packages.emplace_back(std::move(nimPackage));
|
||||||
g_nim.packages.push_back(nimPackage);
|
|
||||||
}
|
}
|
||||||
// check for AOC/titles to download
|
// check for AOC/titles to download
|
||||||
// todo
|
// todo
|
||||||
@ -302,7 +301,7 @@ namespace iosu
|
|||||||
memset(titleIdList, 0, sizeof(uint64) * maxCount);
|
memset(titleIdList, 0, sizeof(uint64) * maxCount);
|
||||||
for (auto& package : g_nim.packages)
|
for (auto& package : g_nim.packages)
|
||||||
{
|
{
|
||||||
titleIdList[count] = _swapEndianU64(package->titleId);
|
titleIdList[count] = _swapEndianU64(package.titleId);
|
||||||
count++;
|
count++;
|
||||||
if (count >= maxCount)
|
if (count >= maxCount)
|
||||||
break;
|
break;
|
||||||
@ -334,7 +333,7 @@ namespace iosu
|
|||||||
return;
|
return;
|
||||||
std::vector<idbeIconCacheEntry_t> idbeIconCache = std::vector<idbeIconCacheEntry_t>();
|
std::vector<idbeIconCacheEntry_t> idbeIconCache = std::vector<idbeIconCacheEntry_t>();
|
||||||
g_nim.titlesLatestVersion = std::vector<NIMTitleLatestVersion>();
|
g_nim.titlesLatestVersion = std::vector<NIMTitleLatestVersion>();
|
||||||
g_nim.packages = std::vector<NIMPackage*>();
|
g_nim.packages.clear();
|
||||||
g_nim.packageListReady = false;
|
g_nim.packageListReady = false;
|
||||||
g_nim.backgroundThreadStarted = false;
|
g_nim.backgroundThreadStarted = false;
|
||||||
std::thread t2(iosuNim_thread);
|
std::thread t2(iosuNim_thread);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user