diff options
Diffstat (limited to 'lib/std/compress/deflate.zig')
| -rw-r--r-- | lib/std/compress/deflate.zig | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/std/compress/deflate.zig b/lib/std/compress/deflate.zig index 7b079a6039..2fe5969067 100644 --- a/lib/std/compress/deflate.zig +++ b/lib/std/compress/deflate.zig @@ -12,6 +12,20 @@ pub const Decompressor = inflate.Decompressor; pub const compressor = deflate.compressor; pub const decompressor = inflate.decompressor; +/// 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`. +/// TODO: remove this smelly function +pub fn copy(dst: []u8, src: []const u8) usize { + if (dst.len <= src.len) { + @memcpy(dst, src[0..dst.len]); + return dst.len; + } else { + @memcpy(dst[0..src.len], src); + return src.len; + } +} + test { _ = @import("deflate/token.zig"); _ = @import("deflate/bits_utils.zig"); |
