| Platform | Resource Type | Close Function | |----------|---------------|----------------| | Windows | HANDLE | CloseHandle | | Linux / macOS | file descriptor | close (syscall or libc) | | WebAssembly (WASI) | fd | fd_close |
Or for a cross-platform abstraction:
init_program :: proc() my_handle := CreateFile(...) runtime.add_cleanup(cleanup_my_resource, &my_handle) odin rqt-close
In Odin, every open deserves a close, every create a destroy. Your future self (and your operating system) will thank you. | Platform | Resource Type | Close Function
A typical Odin solution uses conditional compilation: &my_handle) In Odin
if my_handle != INVALID_HANDLE CloseHandle(my_handle) my_handle = INVALID_HANDLE