mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-08 16:48:18 +00:00
Use or_return on resize/reserve
This commit is contained in:
@@ -147,15 +147,7 @@ grow_buffer :: proc(buf: ^[dynamic]u8) -> (err: compress.Error) {
|
||||
Double until we reach the maximum allowed.
|
||||
*/
|
||||
new_size := min(len(buf) << 1, compress.COMPRESS_OUTPUT_ALLOCATE_MAX)
|
||||
resize(buf, new_size)
|
||||
if len(buf) != new_size {
|
||||
/*
|
||||
Resize failed.
|
||||
*/
|
||||
return .Resize_Failed
|
||||
}
|
||||
|
||||
return nil
|
||||
return resize(buf, new_size)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -510,8 +502,8 @@ inflate_raw :: proc(z: ^$C, expected_output_size := -1, allocator := context.all
|
||||
/*
|
||||
Try to pre-allocate the output buffer.
|
||||
*/
|
||||
reserve(&z.output.buf, expected_output_size)
|
||||
resize (&z.output.buf, expected_output_size)
|
||||
reserve(&z.output.buf, expected_output_size) or_return
|
||||
resize (&z.output.buf, expected_output_size) or_return
|
||||
}
|
||||
|
||||
if len(z.output.buf) != expected_output_size {
|
||||
@@ -654,7 +646,7 @@ inflate_raw :: proc(z: ^$C, expected_output_size := -1, allocator := context.all
|
||||
}
|
||||
|
||||
if int(z.bytes_written) != len(z.output.buf) {
|
||||
resize(&z.output.buf, int(z.bytes_written))
|
||||
resize(&z.output.buf, int(z.bytes_written)) or_return
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user