miniz_oxide icon indicating copy to clipboard operation
miniz_oxide copied to clipboard

Use smallvec lib to encapsulate work with uninitialized memory.

Open Frommi opened this issue 7 years ago • 1 comments

Right now in decompression we may use uninitialized memory without compiler-checked guarantees after with_init_state_only, addressing arrays C-style. More rust-y way would be to encapsulate these unsafe operations in another library: smallvec. Implementation should be pretty straightforward.

In compression miniz_oxide always 0-initializes all buffers, so small tests are slow compared to miniz (which has valgrind warnings here). I am not sure how hard this part would be. Maybe we would be forced to split HashBuffers's dict buffer.

Frommi avatar Mar 04 '18 22:03 Frommi

Yeah, the decompressor initialisation is a bit iffy right now. More safety is always good.

The 0-initialization does indeed slow down the initialization of the compressor, though it's possible that there are redundant memcpys too (as the rust compiler is bad at evading copies that involve stack arrays). I believe the latest versions of miniz added some 0-initialization to avoid the valgrind issues, but flate2 isn't updated to that one.

oyvindln avatar Mar 05 '18 00:03 oyvindln