From owner-freebsd-hackers@FreeBSD.ORG Thu Feb 21 09:53:02 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F0B7816A401 for ; Thu, 21 Feb 2008 09:53:02 +0000 (UTC) (envelope-from wundram@beenic.net) Received: from mail.beenic.net (mail.beenic.net [83.246.72.40]) by mx1.freebsd.org (Postfix) with ESMTP id BDBEC13C45B for ; Thu, 21 Feb 2008 09:53:02 +0000 (UTC) (envelope-from wundram@beenic.net) Received: from [192.168.1.38] (a89-182-158-149.net-htp.de [89.182.158.149]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.beenic.net (Postfix) with ESMTP id EBEB7A44529 for ; Thu, 21 Feb 2008 10:53:00 +0100 (CET) From: "Heiko Wundram (Beenic)" Organization: Beenic Networks GmbH To: freebsd-hackers@freebsd.org Date: Thu, 21 Feb 2008 10:53:15 +0100 User-Agent: KMail/1.9.7 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200802211053.16113.wundram@beenic.net> Subject: OT: Stream structures in bzlib and zlib X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Feb 2008 09:53:03 -0000 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