Close the underlying file handle/descriptor if open
(&self)
| 283 | impl PyMmap { |
| 284 | /// Close the underlying file handle/descriptor if open |
| 285 | fn close_handle(&self) { |
| 286 | #[cfg(unix)] |
| 287 | { |
| 288 | let fd = self.fd.swap(-1); |
| 289 | if fd >= 0 { |
| 290 | unsafe { libc::close(fd) }; |
| 291 | } |
| 292 | } |
| 293 | #[cfg(windows)] |
| 294 | { |
| 295 | let handle = self.handle.swap(INVALID_HANDLE_VALUE as isize); |
| 296 | if handle != INVALID_HANDLE_VALUE as isize { |
| 297 | unsafe { CloseHandle(handle as HANDLE) }; |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | impl Drop for PyMmap { |
no test coverage detected