From e7d6e2d163a060de7b6f2d16f5ece1ae073b7e47 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Sun, 25 Aug 2024 21:07:53 -0400 Subject: [PATCH] Add documentation to `os2.close` Make it explicit that using a stream after closing is like a use-after-free bug. --- core/os/os2/file.odin | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/os/os2/file.odin b/core/os/os2/file.odin index f1c5b1fad..eedf8570c 100644 --- a/core/os/os2/file.odin +++ b/core/os/os2/file.odin @@ -132,6 +132,12 @@ name :: proc(f: ^File) -> string { return _name(f) } +/* + Close a file and its stream. + + Any further use of the file or its stream should be considered to be in the + same class of bugs as a use-after-free. +*/ close :: proc(f: ^File) -> Error { if f != nil { return io.close(f.stream)