Fix memory bug in SnappyNifSink::Append 9/head CouchDB-1.0.2
authorPaul J. Davis <paul.joseph.davis@gmail.com>
Tue, 16 Oct 2018 16:07:58 +0000 (11:07 -0500)
committerPaul J. Davis <paul.joseph.davis@gmail.com>
Tue, 16 Oct 2018 16:07:58 +0000 (11:07 -0500)
commit2038ad13b1d6926468f25adea110028e3c0b4b0c
tree59836045e2b7d3e43111b59354d9ccc7431c0c7e
parent60572a1a4a9fe3cf4e97ccf14df100080481791a
Fix memory bug in SnappyNifSink::Append

Previously `SnappyNifSink` assumed that `GetAppendBuffer` was always
called before `Append`. This turned out to be an invalid assumption.
This was definitely in the land of "How did that even work?". The simple
fix is simple.

This also pre-allocates the write buffer to 8192 bytes which just saves
us from the initial re-allocation on first `Append` since we allocated a
zero length buffer initially.
c_src/snappy_nif.cc