The leak occurred in InitialLoadData when
copying the fetched events from the vector returned by FetchEventsByRange
to the mpShell->m_pCalendar.
This commit is contained in:
jsun%netscape.com 1998-09-21 20:45:43 +00:00
Родитель f1af088431
Коммит a15928d665
1 изменённых файлов: 25 добавлений и 6 удалений

Просмотреть файл

@ -254,7 +254,12 @@ nsresult nsCalScheduler::InitialLoadData()
for ( i = 0; i < pParsedCalList->GetSize(); i++) for ( i = 0; i < pParsedCalList->GetSize(); i++)
{ {
pCal = (NSCalendar*)pParsedCalList->GetAt(i); pCal = (NSCalendar*)pParsedCalList->GetAt(i);
pEventList = pCal->getEvents();
/**
* Change the ownership of the pCal's VEvents' vector
* from pCal to m_pCalendar
*/
pEventList = pCal->changeEventsOwnership();
if (0 != pEventList) if (0 != pEventList)
{ {
for (j = 0; j < pEventList->GetSize(); j++) for (j = 0; j < pEventList->GetSize(); j++)
@ -264,22 +269,36 @@ nsresult nsCalScheduler::InitialLoadData()
mpShell->mpCalendar->addEvent(pEvent); mpShell->mpCalendar->addEvent(pEvent);
} }
} }
/**
* delete pEventList since the vector is no longer needed
* (I only care about the VEvents inside the vector,
* not the vector itself)
*/
delete pEventList; pEventList = 0;
} }
/** /**
* cleanup allocated memory * cleanup allocated memory
*/ */
/**
* Delete each calendar in pParsedCalList.
* I won't delete the events in them because there ownership
* has been changed.
*/
for (i = pParsedCalList->GetSize() - 1; i >= 0; i--)
{
pCal = (NSCalendar *)pParsedCalList->GetAt(i);
delete pCal; pCal = 0;
}
delete [] psDTStart; psDTStart = 0; delete [] psDTStart; psDTStart = 0;
delete [] psDTEnd; psDTEnd = 0; delete [] psDTEnd; psDTEnd = 0;
delete pCalStreamReader; pCalStreamReader = 0; delete pCalStreamReader; pCalStreamReader = 0;
delete capiReader; capiReader = 0; delete capiReader; capiReader = 0;
PR_DestroyMonitor(pThreadMonitor); PR_DestroyMonitor(pThreadMonitor);
PR_DestroyMonitor(pCBReaderMonitor); PR_DestroyMonitor(pCBReaderMonitor);
/*
* todo: need to delete calendars in pParsedCalList without
* deleting events in it
*/
capiStatus = pCapi->CAPI_DestroyStreams(mpShell->mCAPISession, &RcvStream, 1, 0); capiStatus = pCapi->CAPI_DestroyStreams(mpShell->mCAPISession, &RcvStream, 1, 0);
if (CAPI_ERR_OK != capiStatus) if (CAPI_ERR_OK != capiStatus)
return 1; /* XXX: really need to fix this up */ return 1; /* XXX: really need to fix this up */