mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 22:33:08 +00:00
Replaces the inflate API from `inflateStream(reader: anytype, window_slice: []u8)` to `decompressor(allocator: mem.Allocator, reader: anytype, dictionary: ?[]const u8)` and `compressor(allocator: mem.Allocator, writer: anytype, options: CompressorOptions)`
16 lines
576 B
Zig
16 lines
576 B
Zig
const std = @import("std");
|
|
const math = std.math;
|
|
const mem = std.mem;
|
|
|
|
// Copies elements from a source `src` slice into a destination `dst` slice.
|
|
// The copy never returns an error but might not be complete if the destination is too small.
|
|
// Returns the number of elements copied, which will be the minimum of `src.len` and `dst.len`.
|
|
pub fn copy(dst: []u8, src: []const u8) usize {
|
|
if (dst.len <= src.len) {
|
|
mem.copy(u8, dst[0..], src[0..dst.len]);
|
|
} else {
|
|
mem.copy(u8, dst[0..src.len], src[0..]);
|
|
}
|
|
return math.min(dst.len, src.len);
|
|
}
|