MCPcopy Index your code
hub / github.com/RustPython/RustPython / close_handle

Method close_handle

crates/stdlib/src/mmap.rs:285–300  ·  view source on GitHub ↗

Close the underlying file handle/descriptor if open

(&self)

Source from the content-addressed store, hash-verified

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 {

Callers 2

dropMethod · 0.80
closeMethod · 0.80

Calls 3

CloseHandleFunction · 0.85
closeFunction · 0.70
swapMethod · 0.45

Tested by

no test coverage detected