From eb426a5366be816057c6965a3c36b1620cc3c38b Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sun, 2 Aug 2026 09:29:11 +0200 Subject: [PATCH] Improve lifetimes --- src/file/file.odin | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/file/file.odin b/src/file/file.odin index 6641a6f..7ba1e22 100644 --- a/src/file/file.odin +++ b/src/file/file.odin @@ -2,6 +2,7 @@ package file import "core:fmt" import "core:os" +import "core:strings" // TODO: // - list files in directory @@ -9,14 +10,14 @@ import "core:os" // - read file contents // - write file contents -Asset :: struct { +Asset :: struct #all_or_none { path: string, size: i64, data: []u8, } read :: proc(f: ^os.File) -> Asset { - path := os.name(f) + path := strings.clone(os.name(f)) size, err := os.file_size(f) if err != nil { @@ -28,6 +29,7 @@ read :: proc(f: ^os.File) -> Asset { n, read_err := os.read_full(f, data) if read_err != nil { + delete(data) fmt.eprintln("read failed:", read_err, "got", n, "of", size, "bytes") os.exit(1) }