Created
April 12, 2016 00:09
-
-
Save rfdickerson/a59ff08e80e48ba6bcd4049bbd0fc04f to your computer and use it in GitHub Desktop.
zLib Compression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typealias Byte = UInt8 | |
| let size: Int = 100000 | |
| var simpleData = [Byte](repeating: 3, count: size) | |
| var dataCompressed = [Byte](repeating: 6, count: size) | |
| simpleData[3] = 2 | |
| simpleData[4] = 1 | |
| var sizeDataCompressed: uLongf = 0 | |
| let result = compress2( &dataCompressed, &sizeDataCompressed, | |
| &simpleData, uLong(size), Z_BEST_SPEED ) | |
| switch result { | |
| case Z_OK: | |
| print("Everything's OK") | |
| case Z_BUF_ERROR: | |
| print("Buffer error") | |
| default: | |
| print("Some other error") | |
| } | |
| print("Size after compression is: \(sizeDataCompressed)") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It builds and runs, but result is always -5 which means the destination buffer is not large enough to store the result.