diff --git a/core/compress/gzip/gzip.odin b/core/compress/gzip/gzip.odin index 3278d7c1d..457b32bd3 100644 --- a/core/compress/gzip/gzip.odin +++ b/core/compress/gzip/gzip.odin @@ -108,7 +108,9 @@ load_from_slice :: proc(slice: ^[]u8, buf: ^bytes.Buffer, allocator := context.a } load_from_file :: proc(filename: string, buf: ^bytes.Buffer, allocator := context.allocator) -> (err: Error) { - data, ok := os.read_entire_file(filename, context.temp_allocator); + data, ok := os.read_entire_file(filename, allocator); + defer delete(data); + if ok { err = load_from_slice(&data, buf, allocator); return; diff --git a/core/image/png/png.odin b/core/image/png/png.odin index a25fed1ec..5ea9979a8 100644 --- a/core/image/png/png.odin +++ b/core/image/png/png.odin @@ -366,11 +366,9 @@ load_from_slice :: proc(slice: ^[]u8, options: Options = {}, allocator := contex } load_from_file :: proc(filename: string, options: Options = {}, allocator := context.allocator) -> (img: ^Image, err: Error) { - load_file :: proc(filename: string) -> (res: []u8, ok: bool) { - return os.read_entire_file(filename, context.temp_allocator); - } + data, ok := os.read_entire_file(filename, allocator); + defer delete(data); - data, ok := load_file(filename); if ok { img, err = load_from_slice(&data, options, allocator); return;