PR_Free(buffer);
char* urlString; aURL->GetSpec(&urlString); mPluginStreamInfo->SetURL(urlString); nsCRT::free(urlString);    if(mStreamType != nsPluginStreamType_AsFileOnly) {  nsCOMPtr<nsIByteRangeRequest> brr = do_QueryInterface(request); PRInt32 absoluteOffset = 0; PRInt32 amtForwardToPlugin = 0; if (brr) { brr->GetStartRange(&absoluteOffset);   nsPRUintKey key(absoluteOffset);  if (!mDataForwardToRequest) return NS_ERROR_FAILURE;  if (mDataForwardToRequest->Exists(&key)) amtForwardToPlugin = (PRInt32) mDataForwardToRequest->Remove(&key);  mDataForwardToRequest->Put(&key, (void*) (amtForwardToPlugin+aLength)); }  nsCOMPtr<nsIInputStream> stream = aIStream;      nsCOMPtr<nsIOutputStream> outStream; mPluginStreamInfo->GetLocalCachedFileStream(getter_AddRefs(outStream)); if (outStream) { rv = NS_NewInputStreamTee(getter_AddRefs(stream), aIStream, outStream); if (NS_FAILED(rv)) return rv; }  nsCOMPtr<nsIPluginStreamListener2> PStreamListener2 = do_QueryInterface(mPStreamListener); if (PStreamListener2 && brr) rv =  PStreamListener2->OnDataAvailable((nsIPluginStreamInfo*)mPluginStreamInfo, stream, absoluteOffset+amtForwardToPlugin, aLength); else rv =  mPStreamListener->OnDataAvailable((nsIPluginStreamInfo*)mPluginStreamInfo, stream, aLength);    if (NS_FAILED(rv)) request->Cancel(rv); } else {  char* buffer = new char[aLength]; PRUint32 amountRead, amountWrote = 0; rv = aIStream->Read(buffer, aLength, &amountRead);   nsCOMPtr<nsIOutputStream> outStream; mPluginStreamInfo->GetLocalCachedFileStream(getter_AddRefs(outStream)); while (outStream && amountWrote <= amountRead && NS_SUCCEEDED(rv)) rv = outStream->Write(buffer, amountRead, &amountWrote); delete [] buffer; }
nsPluginCacheListener::OnDataAvailable(nsIRequest *request, nsISupports* ctxt,                                        nsIInputStream* aIStream,                                        PRUint32 sourceOffset,                                        PRUint32 aLength){  PRUint32 readlen;  char* buffer = (char*) PR_Malloc(aLength);  // if we don't read from the stream, OnStopRequest will never be called  if(!buffer)    return NS_ERROR_OUT_OF_MEMORY;  nsresult rv = aIStream->Read(buffer, aLength, &readlen);  NS_ASSERTION(aLength == readlen, "nsCacheListener->OnDataAvailable: "               "readlen != aLength");  PR_Free(buffer);  return rv;}