Skip to content

Commit c2e0c18

Browse files
committed
Use the new Allocator API
1 parent f16836d commit c2e0c18

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

libz-rs-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export-symbols = [] # whether the zlib api symbols are publicly exported
1919
custom-prefix = ["export-symbols"] # use the LIBZ_RS_SYS_PREFIX to prefix all exported symbols
2020
testing-prefix = ["export-symbols"] # prefix all symbols with LIBZ_RS_SYS_TEST_ for testing
2121
semver-prefix = ["export-symbols"] # prefix all symbols in a semver-compatible way
22-
gz = ["dep:libc"] # gzip support has to be configued explicitly, to avoid a libc dependency in the core zlib-rs
22+
gz = ["dep:libc"] # gzip support has to be configured explicitly, to avoid a libc dependency in the core zlib-rs
2323

2424
[dependencies]
2525
zlib-rs = { workspace = true, default-features = false }

libz-rs-sys/src/gz.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use zlib_rs::allocate::*;
22
pub use zlib_rs::c_api::*;
33

44
use core::ffi::{c_char, c_int, c_uint, CStr};
5-
use core::mem::size_of;
65
use core::ptr;
76
use libc::{O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_TRUNC, O_WRONLY, SEEK_CUR, SEEK_END};
87
use zlib_rs::deflate::Strategy;
@@ -106,7 +105,7 @@ unsafe fn gzopen_help(path: *const c_char, fd: c_int, mode: *const c_char) -> gz
106105
return ptr::null_mut();
107106
}
108107

109-
let Some(state) = ALLOCATOR.allocate_zeroed(size_of::<GzState>()) else {
108+
let Some(state) = ALLOCATOR.allocate_zeroed_raw::<GzState>() else {
110109
return ptr::null_mut();
111110
};
112111
let state = state.cast::<GzState>().as_mut();
@@ -160,7 +159,7 @@ unsafe fn gzopen_help(path: *const c_char, fd: c_int, mode: *const c_char) -> gz
160159
// Save the path name for error messages
161160
// FIXME: support Windows wide characters for compatibility with zlib-ng
162161
let len = libc::strlen(path) + 1;
163-
let Some(path_copy) = ALLOCATOR.allocate_zeroed(len) else {
162+
let Some(path_copy) = ALLOCATOR.allocate_slice_raw::<u8>(len) else {
164163
free_state(state);
165164
return ptr::null_mut();
166165
};

0 commit comments

Comments
 (0)