Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Feb 2008 10:53:15 +0100
From:      "Heiko Wundram (Beenic)" <wundram@beenic.net>
To:        freebsd-hackers@freebsd.org
Subject:   OT: Stream structures in bzlib and zlib
Message-ID:  <200802211053.16113.wundram@beenic.net>

next in thread | raw e-mail | index | archive | help
Hey all!

I'm currently working on a project using zlib and bzlib, and I'm currently 
slightly stomped by the fact that both define the input buffer in their 
stream structure as non-const. Generally, I'd assume that the input buffer is 
never changed (by any of the compression/decompression functions), and that 
it should thus be defined as a const pointer. My wrappers for them assume the 
same, of course.

I've read the zlib manual, and there is some obscure function which uses the 
input buffer as temporary storage (restoring it on exit), but at least for 
the code paths I'm taking (the standard deflate/inflate), I'm pretty 
confident after skimming through the sources that they don't modify the input 
buffer and don't call into the function that does modify it (and thus a 
const_cast<> to set it up is perfectly okay).

For bzlib, I'm less sure, as the sources are somewhat convoluted, and I 
probably didn't find all references to the input buffer in the code paths I 
checked.

Before I go and test whether bzlib modifies the input buffer for temporaries 
(by simply passing it data in a RO segment and checking whether I get a 
SIGSEGV), is there anyone out there who's hit the same "problem" before and 
might shed some more insight whether I'll have to copy the data before 
setting it up in a stream structure as input?

Thanks for any reply!

-- 
Heiko Wundram
Product & Application Development



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802211053.16113.wundram>