aboutsummaryrefslogtreecommitdiff
path: root/core/compress
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2021-09-19 12:19:01 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2021-09-19 12:19:01 +0200
commit72fe1e88a3be6b9cd560d9b4143593421517ad57 (patch)
tree7fb1580ca6e902db35b1094d93b6269f3e73528f /core/compress
parent505113ee2d560816dbe33dbee5a471bf85b12233 (diff)
Make sure to `delete` on the right allocator.
Diffstat (limited to 'core/compress')
-rw-r--r--core/compress/gzip/gzip.odin7
-rw-r--r--core/compress/zlib/zlib.odin7
2 files changed, 9 insertions, 5 deletions
diff --git a/core/compress/gzip/gzip.odin b/core/compress/gzip/gzip.odin
index 6ea4b3559..1a72500bf 100644
--- a/core/compress/gzip/gzip.odin
+++ b/core/compress/gzip/gzip.odin
@@ -104,12 +104,14 @@ GZIP_MAX_PAYLOAD_SIZE :: int(max(u32le))
load :: proc{load_from_slice, load_from_file, load_from_context}
load_from_file :: proc(filename: string, buf: ^bytes.Buffer, expected_output_size := -1, allocator := context.allocator) -> (err: Error) {
- data, ok := os.read_entire_file(filename, allocator)
+ context.allocator = allocator
+
+ data, ok := os.read_entire_file(filename)
defer delete(data)
err = E_General.File_Not_Found
if ok {
- err = load_from_slice(data, buf, len(data), expected_output_size, allocator)
+ err = load_from_slice(data, buf, len(data), expected_output_size)
}
return
}
@@ -125,6 +127,7 @@ load_from_slice :: proc(slice: []u8, buf: ^bytes.Buffer, known_gzip_size := -1,
}
load_from_context :: proc(z: ^$C, buf: ^bytes.Buffer, known_gzip_size := -1, expected_output_size := -1, allocator := context.allocator) -> (err: Error) {
+ context.allocator = allocator
buf := buf
expected_output_size := expected_output_size
diff --git a/core/compress/zlib/zlib.odin b/core/compress/zlib/zlib.odin
index f428dc11b..9ae980042 100644
--- a/core/compress/zlib/zlib.odin
+++ b/core/compress/zlib/zlib.odin
@@ -495,6 +495,7 @@ inflate_from_context :: proc(using ctx: ^compress.Context_Memory_Input, raw := f
@(optimization_mode="speed")
inflate_raw :: proc(z: ^$C, expected_output_size := -1, allocator := context.allocator) -> (err: Error) #no_bounds_check {
+ context.allocator = allocator
expected_output_size := expected_output_size
/*
@@ -526,9 +527,9 @@ inflate_raw :: proc(z: ^$C, expected_output_size := -1, allocator := context.all
defer free(z_offset)
defer free(codelength_ht)
- z_repeat = allocate_huffman_table(allocator=context.allocator) or_return
- z_offset = allocate_huffman_table(allocator=context.allocator) or_return
- codelength_ht = allocate_huffman_table(allocator=context.allocator) or_return
+ z_repeat = allocate_huffman_table() or_return
+ z_offset = allocate_huffman_table() or_return
+ codelength_ht = allocate_huffman_table() or_return
final := u32(0)
type := u32(0)