Skip to content

Commit ff8ed2f

Browse files
committed
Move MmpPostponedTlsList to heap
1 parent 8641a07 commit ff8ed2f

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

MemoryModule/MmpTlsFiber.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ typedef struct _MMP_POSTPONED_TLS {
1212

1313
}MMP_POSTPONED_TLS, * PMMP_POSTPONED_TLS;
1414

15-
std::vector<MMP_POSTPONED_TLS>MmpPostponedTlsList;
15+
std::vector<MMP_POSTPONED_TLS>* MmpPostponedTlsList;
1616

1717
HANDLE MmpPostponedTlsEvent;
1818
CRITICAL_SECTION MmpPostponedTlsLock;
@@ -23,13 +23,13 @@ DWORD WINAPI MmpReleasePostponedTlsWorker(PVOID) {
2323
DWORD waitTime = INFINITE;
2424

2525
while (true) {
26-
DWORD signal = WaitForSingleObject(MmpPostponedTlsEvent, waitTime);
26+
WaitForSingleObject(MmpPostponedTlsEvent, waitTime);
2727

2828
EnterCriticalSection(&MmpPostponedTlsLock);
2929

30-
auto iter = MmpPostponedTlsList.begin();
30+
auto iter = MmpPostponedTlsList->begin();
3131

32-
while (iter != MmpPostponedTlsList.end()) {
32+
while (iter != MmpPostponedTlsList->end()) {
3333
const auto& item = *iter;
3434
GetExitCodeThread(item.hThread, &code);
3535

@@ -57,12 +57,12 @@ DWORD WINAPI MmpReleasePostponedTlsWorker(PVOID) {
5757
RtlReleaseSRWLockExclusive(&MmpGlobalDataPtr->MmpTls->MmpTlsListLock);
5858

5959
CloseHandle(item.hThread);
60-
iter = MmpPostponedTlsList.erase(iter);
60+
iter = MmpPostponedTlsList->erase(iter);
6161
}
6262

6363
}
6464

65-
waitTime = MmpPostponedTlsList.empty() ? INFINITE : 1000;
65+
waitTime = MmpPostponedTlsList->empty() ? INFINITE : 1000;
6666

6767
LeaveCriticalSection(&MmpPostponedTlsLock);
6868
}
@@ -100,7 +100,7 @@ VOID WINAPI MmpQueuePostponedTls(PMMP_TLSP_RECORD record) {
100100

101101
EnterCriticalSection(&MmpPostponedTlsLock);
102102

103-
MmpPostponedTlsList.push_back(item);
103+
MmpPostponedTlsList->push_back(item);
104104
SetEvent(MmpPostponedTlsEvent);
105105

106106
LeaveCriticalSection(&MmpPostponedTlsLock);
@@ -109,6 +109,7 @@ VOID WINAPI MmpQueuePostponedTls(PMMP_TLSP_RECORD record) {
109109
VOID MmpTlsFiberInitialize() {
110110
InitializeCriticalSection(&MmpPostponedTlsLock);
111111
MmpPostponedTlsEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
112+
MmpPostponedTlsList = new(HeapAlloc(GetProcessHeap(), 0, sizeof(std::vector<MMP_POSTPONED_TLS>))) std::vector<MMP_POSTPONED_TLS>();
112113

113114
CreateThread(nullptr, 0, MmpReleasePostponedTlsWorker_Wrap, nullptr, 0, nullptr);
114115
}

0 commit comments

Comments
 (0)