Zero fill iovecs starting at the given byte offset for the given length. # Safety Caller must ensure iovecs point to valid, writable memory of sufficient size.
(iovecs: &[libc::iovec], start: usize, len: usize)
| 227 | /// # Safety |
| 228 | /// Caller must ensure iovecs point to valid, writable memory of sufficient size. |
| 229 | pub unsafe fn zero_fill_iovecs(iovecs: &[libc::iovec], start: usize, len: usize) { |
| 230 | let mut remaining = len; |
| 231 | let mut pos = 0usize; |
| 232 | for iov in iovecs { |
| 233 | let iov_end = pos + iov.iov_len; |
| 234 | if iov_end <= start || remaining == 0 { |
| 235 | pos = iov_end; |
| 236 | continue; |
| 237 | } |
| 238 | let iov_start = start.saturating_sub(pos); |
| 239 | let available = iov.iov_len - iov_start; |
| 240 | let count = min(available, remaining); |
| 241 | // SAFETY: iov_base is valid for iov_len bytes per caller contract. |
| 242 | unsafe { |
| 243 | let dst = iov.iov_base.cast::<u8>().add(iov_start); |
| 244 | ptr::write_bytes(dst, 0, count); |
| 245 | } |
| 246 | remaining -= count; |
| 247 | if remaining == 0 { |
| 248 | break; |
| 249 | } |
| 250 | pos = iov_end; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | /// Gather bytes from iovecs starting at the given byte offset into `dst`. |
| 255 | /// |
no test coverage detected