nsIStringInputStream in C++

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

nsIStringInputStream in C++

zen-3
Hi all,

How can I use the nsIStringInputStream in C++?
Below is my code:

//****
nsCOMPtr<nsIStringInputStream> newPostStream;
char* aStream = "&key=123";
newPostStream->AdoptData(aStream, strlen(aStream));
//***

I'm not sure where my mistake was & I always get "the memory could not
be read" when run on firefox, please advice...

Thanks.
_______________________________________________
Mozilla-netlib mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-netlib
Reply | Threaded
Open this post in threaded view
|

Re: nsIStringInputStream in C++

zen-3
zen wrote:

> Hi all,
>
> How can I use the nsIStringInputStream in C++?
> Below is my code:
>
> //****
> nsCOMPtr<nsIStringInputStream> newPostStream;
> char* aStream = "&key=123";
> newPostStream->AdoptData(aStream, strlen(aStream));
> //***
>
> I'm not sure where my mistake was & I always get "the memory could not
> be read" when run on firefox, please advice...
>
> Thanks.

Hi,
is my declaration proper? how can i create an instance of the
nsIStringInputStream? compiler complaints 'do_CreateInstance' is
undeclared identifier.

Please advice...
-zen
_______________________________________________
Mozilla-netlib mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-netlib
Reply | Threaded
Open this post in threaded view
|

Re: nsIStringInputStream in C++

Christian Biesinger
zen wrote:
> is my declaration proper? how can i create an instance of the
> nsIStringInputStream? compiler complaints 'do_CreateInstance' is
> undeclared identifier.

Then you need to include the right header. That's
nsComponentManagerUtils.h in this case.

Note that you can't use AdoptData for a literal string; when you do
that, the stream will try to free the data, which will crash. Use ShareData.

smime.p7s (6K) Download Attachment