Skip to content

Commit 7ff5564

Browse files
committed
Add loc := #caller_location to read_entire_file
1 parent ef982f2 commit 7ff5564

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

core/encoding/hxa/read.odin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ Read_Error :: enum {
1414
read_from_file :: proc(filename: string, print_error := false, allocator := context.allocator, loc := #caller_location) -> (file: File, err: Read_Error) {
1515
context.allocator = allocator
1616

17-
data, data_err := os.read_entire_file(filename, allocator)
17+
data, data_err := os.read_entire_file(filename, allocator, loc)
1818
if data_err != nil {
1919
err = .Unable_To_Read_File
20-
delete(data, allocator, loc)
20+
delete(data, allocator)
2121
return
2222
}
2323
file, err = read(data, filename, print_error, allocator)

core/os/os2/file_util.odin

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,17 @@ read_entire_file :: proc{
107107
}
108108

109109
@(require_results)
110-
read_entire_file_from_path :: proc(name: string, allocator: runtime.Allocator) -> (data: []byte, err: Error) {
110+
read_entire_file_from_path :: proc(name: string, allocator: runtime.Allocator, loc := #caller_location) -> (data: []byte, err: Error) {
111111
f, ferr := open(name)
112112
if ferr != nil {
113113
return nil, ferr
114114
}
115115
defer close(f)
116-
return read_entire_file_from_file(f, allocator)
116+
return read_entire_file_from_file(f=f, allocator=allocator, loc=loc)
117117
}
118118

119119
@(require_results)
120-
read_entire_file_from_file :: proc(f: ^File, allocator: runtime.Allocator) -> (data: []byte, err: Error) {
120+
read_entire_file_from_file :: proc(f: ^File, allocator: runtime.Allocator, loc := #caller_location) -> (data: []byte, err: Error) {
121121
size: int
122122
has_size := false
123123
if size64, serr := file_size(f); serr == nil {
@@ -129,7 +129,7 @@ read_entire_file_from_file :: proc(f: ^File, allocator: runtime.Allocator) -> (d
129129

130130
if has_size && size > 0 {
131131
total: int
132-
data = make([]byte, size, allocator) or_return
132+
data = make([]byte, size, allocator, loc) or_return
133133
for total < len(data) {
134134
n: int
135135
n, err = read(f, data[total:])
@@ -145,7 +145,7 @@ read_entire_file_from_file :: proc(f: ^File, allocator: runtime.Allocator) -> (d
145145
return
146146
} else {
147147
buffer: [1024]u8
148-
out_buffer := make([dynamic]u8, 0, 0, allocator)
148+
out_buffer := make([dynamic]u8, 0, 0, allocator, loc)
149149
total := 0
150150
for {
151151
n: int

0 commit comments

Comments
 (0)