This PR copies self into contiguous data before deflating and inflating, regardless of whether self is contiguous or discontiguous.
The defensive patch consumes more temporary memory. It's better than random runtime crash.
I could not add tests for that as I saw the crashs randomly on devices and not on the simulator.
Alternative fixes:
Although I think about other fixes, they need some more work.
changing createZStream to withZStream<T>(block: (z_stream) -> T) -> T may reduce memory copy for already contiguous data (by Swift lib or Foundation)
using enumerateBytes in deflating and inflating could directly read both contiguous and discontiguous data
minimum changes to fix #22
This PR copies self into contiguous data before deflating and inflating, regardless of whether self is contiguous or discontiguous. The defensive patch consumes more temporary memory. It's better than random runtime crash.
I could not add tests for that as I saw the crashs randomly on devices and not on the simulator.
Alternative fixes:
Although I think about other fixes, they need some more work.
createZStream
towithZStream<T>(block: (z_stream) -> T) -> T
may reduce memory copy for already contiguous data (by Swift lib or Foundation)enumerateBytes
in deflating and inflating could directly read both contiguous and discontiguous data