From 782be6b659e73567db35da7d02eab98e68249f2d Mon Sep 17 00:00:00 2001 From: "davidm%netscape.com" Date: Wed, 19 Apr 2000 04:54:53 +0000 Subject: [PATCH] 28412 metaDataLength is wrong in nsCachedNetData::Deserialize. Add routines to build stream from char* and length git-svn-id: svn://10.0.0.236/trunk@66416 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/io/nsIStringStream.cpp | 22 ++++++++++++++++++++++ mozilla/xpcom/io/nsIStringStream.h | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/mozilla/xpcom/io/nsIStringStream.cpp b/mozilla/xpcom/io/nsIStringStream.cpp index a31b621ef41..ac7721b34b8 100644 --- a/mozilla/xpcom/io/nsIStringStream.cpp +++ b/mozilla/xpcom/io/nsIStringStream.cpp @@ -493,3 +493,25 @@ extern "C" NS_COM nsresult NS_NewCharIOStream( { return NS_NewCharOutputStream(aStreamResult, aStringToChange); } + +//---------------------------------------------------------------------------------------- +extern "C" NS_COM nsresult NS_NewByteInputStream( + nsISupports** aStreamResult, + const char* aStringToRead, + PRInt32 aLength) + // Factory method to get an nsInputStream from a string. Result will implement all the + // file stream interfaces in nsIFileStream.h +//---------------------------------------------------------------------------------------- +{ + NS_PRECONDITION(aStreamResult != nsnull, "null ptr"); + if (! aStreamResult) + return NS_ERROR_NULL_POINTER; + + ConstCharImpl* stream = new ConstCharImpl(aStringToRead, aLength); + if (! stream) + return NS_ERROR_OUT_OF_MEMORY; + + NS_ADDREF(stream); + *aStreamResult = (nsISupports*)(void*)stream; + return NS_OK; +} \ No newline at end of file diff --git a/mozilla/xpcom/io/nsIStringStream.h b/mozilla/xpcom/io/nsIStringStream.h index 8a64eb91f68..cce458cdfe2 100644 --- a/mozilla/xpcom/io/nsIStringStream.h +++ b/mozilla/xpcom/io/nsIStringStream.h @@ -75,4 +75,11 @@ extern "C" NS_COM nsresult NS_NewCharIOStream( // Factory method to get an nsOutputStream to a string. Result will implement all the // file stream interfaces in nsIFileStream.h +//---------------------------------------------------------------------------------------- +extern "C" NS_COM nsresult NS_NewByteInputStream( + nsISupports** aStreamResult, + const char* aStringToRead, + PRInt32 aLength); + // Factory method to get an nsInputStream from a string. Result will implement all the + // #endif /* nsIStringStream_h___ */