cvmfs/cvmfs — pull request #334 by reneme (2014-01-07 16:39:34+00:00)
Title: FIX: Coverity Defect / Memory Leak in Compression

This is a fix for a Coverity complaint and actually needed some refactoring.
Turns out, that **zlib** sometimes claims to need additional memory for compressed data output and needs to rerun `deflate()`. I assumed, that such a claim would always actually produce more data but apparently it doesn't!

It would have bloated the core processing code to keep track of which allocated buffers were actually used and which needed cleanup. Additionally it would have occasionally allocated useless buffers only to delete them again. Thus I moved this buffer handling into the `Chunk`, which now keeps a single buffer until it is completely filled with compression data. In case there is more data to be compressed, a new buffer is allocated and the old one is finalized and sent to the asynchronous upload module.

Interestingly Coverity even sometimes points to design flaws, which is nice. :o)

Moreover this contains some additions to the `Buffer` class, to simplify the above-described implementation and test code for the added `Buffer` functionality.