google / open-vcdiff

An encoder/decoder for the VCDIFF (RFC3284) format
Apache License 2.0
186 stars 52 forks source link

vcdecoder: add memory-based output interface #77

Open zonque opened 6 years ago

zonque commented 6 years ago

Currently, the VCDiffStreamingDecoder class expects applications to call into ::StartDecoding() with a dictionary, and then maintains an internal buffer (decoded_target_) to accumulate pending output bytes. These are then written through ::AppendNewOutputText() and ::FlushDecodedTarget().

The problem with this implementation is that the allocation of this intermediate buffer may fail, which will then result in the application abort with a trap.

This patch adds an alternative interface that does not lead to internal allocation. StartDecoding() may now optionally be called with an output buffer and a maximum length, and DecodeChunk() may be called without an OutputString parameter. If operated this way, the decoder will directly write to the provided memory buffer, which can, for instance, be mmap()ed on a block device.

The old interface is kept around for full compatibility.

This should address #12.

googlebot commented 6 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers
zonque commented 6 years ago

I signed it!

googlebot commented 6 years ago

CLAs look good, thanks!