Fixed memory leaks.
This commit is contained in:
parent
585d9101b7
commit
a1761d8a7b
@ -34,17 +34,18 @@ VOID CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHig
|
|||||||
|
|
||||||
int TestSynchWaitableTimerAPC(int argc, char* argv[])
|
int TestSynchWaitableTimerAPC(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
HANDLE hTimer;
|
int status = -1;
|
||||||
|
HANDLE hTimer = NULL;
|
||||||
BOOL bSuccess;
|
BOOL bSuccess;
|
||||||
LARGE_INTEGER due;
|
LARGE_INTEGER due;
|
||||||
APC_DATA* apcData;
|
APC_DATA* apcData = NULL;
|
||||||
|
|
||||||
apcData = (APC_DATA*) malloc(sizeof(APC_DATA));
|
apcData = (APC_DATA*) malloc(sizeof(APC_DATA));
|
||||||
g_Event = CreateEvent(NULL, TRUE, FALSE, NULL);
|
g_Event = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
|
hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
|
||||||
|
|
||||||
if (!hTimer)
|
if (!hTimer)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
due.QuadPart = -15000000LL; /* 1.5 seconds */
|
due.QuadPart = -15000000LL; /* 1.5 seconds */
|
||||||
|
|
||||||
@ -52,18 +53,24 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[])
|
|||||||
bSuccess = SetWaitableTimer(hTimer, &due, 2000, TimerAPCProc, apcData, FALSE);
|
bSuccess = SetWaitableTimer(hTimer, &due, 2000, TimerAPCProc, apcData, FALSE);
|
||||||
|
|
||||||
if (!bSuccess)
|
if (!bSuccess)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
if (WaitForSingleObject(g_Event, INFINITE) != WAIT_OBJECT_0)
|
if (WaitForSingleObject(g_Event, INFINITE) != WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
printf("WaitForSingleObject failed (%d)\n", GetLastError());
|
printf("WaitForSingleObject failed (%d)\n", GetLastError());
|
||||||
return -1;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(hTimer);
|
status = 0;
|
||||||
CloseHandle(g_Event);
|
|
||||||
free(apcData);
|
|
||||||
|
|
||||||
return 0;
|
cleanup:
|
||||||
|
if (hTime)
|
||||||
|
CloseHandle(hTimer);
|
||||||
|
if (g_Event)
|
||||||
|
CloseHandle(g_Event);
|
||||||
|
if (apcData)
|
||||||
|
free(apcData);
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user