1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

docs: add more documentation to each of the modules in vlib (#13043)

This commit is contained in:
jeffmikels
2022-01-07 06:28:50 -05:00
committed by GitHub
parent 287331bc19
commit 6e6d51a1c9
16 changed files with 266 additions and 71 deletions

View File

@ -1,6 +1,7 @@
## Description:
`compress.zlib` implements zlib compression and decompression of binary data.
`compress.zlib` is a module that assists in the compression and
decompression of binary data using `zlib` compression
## Examples:

View File

@ -8,6 +8,8 @@ pub const max_size = u64(1 << 31)
fn C.tdefl_compress_mem_to_heap(source_buf voidptr, source_buf_len usize, out_len &usize, flags int) voidptr
fn C.tinfl_decompress_mem_to_heap(source_buf voidptr, source_buf_len usize, out_len &usize, flags int) voidptr
// compresses an array of bytes using zlib and returns the compressed bytes in a new array
// Example: compressed := zlib.compress(b) ?
[manualfree]
pub fn compress(data []byte) ?[]byte {
if u64(data.len) > zlib.max_size {
@ -33,6 +35,8 @@ pub fn compress(data []byte) ?[]byte {
return copy
}
// decompresses an array of bytes using zlib and returns the decompressed bytes in a new array
// Example: decompressed := zlib.decompress(b) ?
[manualfree]
pub fn decompress(data []byte) ?[]byte {
mut out_len := usize(0)