Skip to content

Commit 3c2f02a

Browse files
committed
struct COVER_dictSelection_t: pass by-reference
1 parent 7725ad0 commit 3c2f02a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/dictBuilder/cover.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct COVER_tryParameters_data_t<'a, 'b> {
110110
dictBufferCapacity: size_t,
111111
parameters: ZDICT_cover_params_t,
112112
}
113-
#[derive(Copy, Clone)]
113+
#[derive(Clone)]
114114
#[repr(C)]
115115
pub(super) struct COVER_dictSelection_t {
116116
dictContent: *mut u8,
@@ -977,7 +977,7 @@ pub(super) fn COVER_best_start(best: &mut COVER_best_t) {
977977
pub(super) unsafe fn COVER_best_finish(
978978
best: &mut COVER_best_t,
979979
parameters: ZDICT_cover_params_t,
980-
selection: COVER_dictSelection_t,
980+
selection: &COVER_dictSelection_t,
981981
) {
982982
let dict = selection.dictContent as *mut core::ffi::c_void;
983983
let compressedSize = selection.totalCompressedSize;
@@ -1019,8 +1019,8 @@ pub(super) fn COVER_dictSelectionError(error: size_t) -> COVER_dictSelection_t {
10191019
setDictSelection(core::ptr::null_mut(), 0, error)
10201020
}
10211021

1022-
pub(super) fn COVER_dictSelectionIsError(selection: COVER_dictSelection_t) -> core::ffi::c_uint {
1023-
(ERR_isError(selection.totalCompressedSize) || (selection.dictContent).is_null())
1022+
pub(super) fn COVER_dictSelectionIsError(selection: &COVER_dictSelection_t) -> core::ffi::c_uint {
1023+
(ERR_isError(selection.totalCompressedSize) || selection.dictContent.is_null())
10241024
as core::ffi::c_int as core::ffi::c_uint
10251025
}
10261026

@@ -1179,11 +1179,11 @@ unsafe fn COVER_tryParameters(opaque: *mut core::ffi::c_void) {
11791179
totalCompressedSize,
11801180
);
11811181

1182-
if COVER_dictSelectionIsError(selection) != 0 && displayLevel >= 1 {
1182+
if COVER_dictSelectionIsError(&selection) != 0 && displayLevel >= 1 {
11831183
eprintln!("Failed to select dictionary");
11841184
}
11851185
drop(dict);
1186-
COVER_best_finish((*data).best, parameters, selection);
1186+
COVER_best_finish((*data).best, parameters, &selection);
11871187
free(data as *mut core::ffi::c_void);
11881188
COVER_map_destroy(&mut activeDmers);
11891189
COVER_dictSelectionFree(selection);

lib/dictBuilder/fastcover.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ unsafe fn FASTCOVER_tryParameters(opaque: *mut core::ffi::c_void) {
438438
let mut segmentFreqs: Box<[u16]> = Box::from(vec![0u16; 1 << ctx.f]);
439439
let mut dict: Box<[u8]> = Box::from(vec![0; dictBufferCapacity]);
440440
let mut selection = COVER_dictSelectionError(Error::GENERIC.to_error_code());
441+
441442
let displayLevel = ctx.displayLevel;
442443
let mut freqs = ctx.freqs.clone();
443444

@@ -464,12 +465,12 @@ unsafe fn FASTCOVER_tryParameters(opaque: *mut core::ffi::c_void) {
464465
ctx.offsets.as_ptr().cast_mut(),
465466
totalCompressedSize,
466467
);
467-
if COVER_dictSelectionIsError(selection) != 0 && displayLevel >= 1 {
468+
if COVER_dictSelectionIsError(&selection) != 0 && displayLevel >= 1 {
468469
eprintln!("Failed to select dictionary");
469470
}
470471

471472
drop(dict);
472-
COVER_best_finish((*data).best.as_mut().unwrap(), parameters, selection);
473+
COVER_best_finish((*data).best.as_mut().unwrap(), parameters, &selection);
473474
free(data as *mut core::ffi::c_void);
474475
drop(segmentFreqs);
475476
COVER_dictSelectionFree(selection);

0 commit comments

Comments
 (0)