diff options
author | gordon%netscape.com <devnull@localhost> | 1999-03-04 19:27:19 +0000 |
---|---|---|
committer | gordon%netscape.com <devnull@localhost> | 1999-03-04 19:27:19 +0000 |
commit | 6cbd3718227a1162d059f8c74cb6615fd2240ed1 (patch) | |
tree | 2ad91a5933089ac4e0c40a58c1e00c2a871398ae | |
parent | 2546e5b46d8c1ed2caa0e4fa899098393a145d31 (diff) | |
download | nspr-hg-6cbd3718227a1162d059f8c74cb6615fd2240ed1.tar.gz |
Bug fix for #3410 & #3403 by Simon Fraser, reviewed by Gordon Sheridan. Stop leaking UPPs everytime we do a file read.
-rw-r--r-- | pr/src/md/mac/macio.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pr/src/md/mac/macio.c b/pr/src/md/mac/macio.c index ab1e8697..e7062a77 100644 --- a/pr/src/md/mac/macio.c +++ b/pr/src/md/mac/macio.c @@ -243,11 +243,19 @@ PRInt32 ReadWriteProc(PRFileDesc *fd, void *buf, PRUint32 bytes, IOOperation op) goto ErrorExit; } #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; |