Bug fix for #3410 & #3403 by Simon Fraser, reviewed by Gordon Sheridan. Stop leaking UPPs everytime we do a file read.

This commit is contained in:
gordon%netscape.com 1999-03-04 19:27:19 +00:00
Родитель 7a5ab00937
Коммит 3f58f95ebd
1 изменённых файлов: 10 добавлений и 2 удалений

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

@ -244,10 +244,18 @@ PRInt32 ReadWriteProc(PRFileDesc *fd, void *buf, PRUint32 bytes, IOOperation op)
}
#endif
{
static IOCompletionUPP sCompletionUPP = NULL;
/* allocate the callback Universal Procedure Pointer (UPP). This actually allocates
a 32 byte Ptr in the heap, so only do this once
*/
if (!sCompletionUPP)
sCompletionUPP = NewIOCompletionProc((ProcPtr)&AsyncIOCompletion);
/* grab the thread so we know which one to post to at completion */
pbAsync.thread = me;
pbAsync.pb.ioParam.ioCompletion = NewIOCompletionProc((ProcPtr)&AsyncIOCompletion);
pbAsync.pb.ioParam.ioCompletion = sCompletionUPP;
pbAsync.pb.ioParam.ioResult = noErr;
pbAsync.pb.ioParam.ioRefNum = refNum;
pbAsync.pb.ioParam.ioBuffer = buf;