Use regular allocator from png+gzip's load_from_file.
I would've used `os.stream_from_handle`, but: - Parts of it seem to be implemented for Windows only at the moment. - PNG's `peek_data` using that stream didn't manage to rewind and thus tried to parse the data after the header as the header. Two things must happen: - The `os.stream_from_handle` implementation needs to be fixed. - PNG and GZIP's parsers need to be able to handle streams that can't rewind or seek (backward). Those fixes are on my TODO list but are exceed the scope of this patch.
This commit is contained in:
1 parent
58e023e0cf
commit
06f1eaa153
2 files changed
+5
-5
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user