diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-10-28 11:13:34 +0100 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-10-28 11:13:34 +0100 |
| commit | 7ff556421fdb0308840a73662c5fa4870f8bed49 (patch) | |
| tree | 65a2b3b8d03a3055ccd5161858ede57ca2df3790 | |
| parent | ef982f2938dbef36d0a42f10807e088424ac0caf (diff) | |
Add `loc := #caller_location` to `read_entire_file`
| -rw-r--r-- | core/encoding/hxa/read.odin | 4 | ||||
| -rw-r--r-- | core/os/os2/file_util.odin | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/core/encoding/hxa/read.odin b/core/encoding/hxa/read.odin index 04dcab817..1f1c3633e 100644 --- a/core/encoding/hxa/read.odin +++ b/core/encoding/hxa/read.odin @@ -14,10 +14,10 @@ Read_Error :: enum { read_from_file :: proc(filename: string, print_error := false, allocator := context.allocator, loc := #caller_location) -> (file: File, err: Read_Error) { context.allocator = allocator - data, data_err := os.read_entire_file(filename, allocator) + data, data_err := os.read_entire_file(filename, allocator, loc) if data_err != nil { err = .Unable_To_Read_File - delete(data, allocator, loc) + delete(data, allocator) return } file, err = read(data, filename, print_error, allocator) diff --git a/core/os/os2/file_util.odin b/core/os/os2/file_util.odin index 13d6db661..579acd2da 100644 --- a/core/os/os2/file_util.odin +++ b/core/os/os2/file_util.odin @@ -107,17 +107,17 @@ read_entire_file :: proc{ } @(require_results) -read_entire_file_from_path :: proc(name: string, allocator: runtime.Allocator) -> (data: []byte, err: Error) { +read_entire_file_from_path :: proc(name: string, allocator: runtime.Allocator, loc := #caller_location) -> (data: []byte, err: Error) { f, ferr := open(name) if ferr != nil { return nil, ferr } defer close(f) - return read_entire_file_from_file(f, allocator) + return read_entire_file_from_file(f=f, allocator=allocator, loc=loc) } @(require_results) -read_entire_file_from_file :: proc(f: ^File, allocator: runtime.Allocator) -> (data: []byte, err: Error) { +read_entire_file_from_file :: proc(f: ^File, allocator: runtime.Allocator, loc := #caller_location) -> (data: []byte, err: Error) { size: int has_size := false if size64, serr := file_size(f); serr == nil { @@ -129,7 +129,7 @@ read_entire_file_from_file :: proc(f: ^File, allocator: runtime.Allocator) -> (d if has_size && size > 0 { total: int - data = make([]byte, size, allocator) or_return + data = make([]byte, size, allocator, loc) or_return for total < len(data) { n: int n, err = read(f, data[total:]) @@ -145,7 +145,7 @@ read_entire_file_from_file :: proc(f: ^File, allocator: runtime.Allocator) -> (d return } else { buffer: [1024]u8 - out_buffer := make([dynamic]u8, 0, 0, allocator) + out_buffer := make([dynamic]u8, 0, 0, allocator, loc) total := 0 for { n: int |