Re: [Evolution-hackers] CamelStreamMem ==> CamelStream ?



On Fri, 2006-11-17 at 09:06 +0100, Jules Colding wrote:
> On Thu, 2006-11-16 at 21:46 +0530, Srinivasa Ragavan wrote:
> > On Thu, 2006-11-16 at 15:10 +0100, Jules Colding wrote:
> > > Hi,
> > > 
> > > I'm looking for an easy way to transfer the content of a CamelStreamMem
> > > to a CamelStream without having a duplicate of the content around. Does
> > > anyone know a non-hackish(*) way to do that?
> > You can use CamelStreamMem as CamelStream directly. 
> 
> Yes, but the API is:
> 
> CamelStream *camel_data_cache_add()
> 
> So I need a way to move to content of a preexisting CamelStreamMem over
> to the stream that was returned by camel_data_cache_add() and I like to
> do that without copying any memory.

what you want to do is:

camel_stream_reset (mem_stream);
camel_stream_write_to_stream (mem_stream, cache_stream);
camel_stream_reset (cache_stream);

it's important that the mem_stream be "reset" so it starts reading from
the beginning of the stream (it may already be, in which case you won't
need to explicitly do it again here)

resetting the cache_stream afterward is, again, up to you - if you plan
on appending to it, you won't want to reset it - but I'm assuming you
plan on reading the content back again later and not appending more data
to it :)

Jeff

-- 
Jeffrey Stedfast
Desktop Hacker - Novell, Inc.
fejj novell com  - www.novell.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]