@@ -1165,27 +1165,18 @@ unsafe fn COVER_tryParameters(opaque: *mut core::ffi::c_void) {
11651165 let totalCompressedSize = Error :: GENERIC . to_error_code ( ) ;
11661166 let dict = malloc ( dictBufferCapacity) as * mut u8 ;
11671167 let mut selection = COVER_dictSelectionError ( Error :: GENERIC . to_error_code ( ) ) ;
1168- let suffixSize = {
1169- let suffix = & ( * ctx) . suffix ;
1170- suffix. len ( )
1171- } ;
1172- let freqs = malloc ( suffixSize. wrapping_mul ( :: core:: mem:: size_of :: < u32 > ( ) ) ) as * mut u32 ;
1168+ let mut freqs = ( * ctx) . freqs . clone ( ) ;
11731169 let displayLevel = ( * ctx) . displayLevel ;
11741170 let mut activeDmers =
11751171 COVER_map_t :: new ( ( parameters. k ) . wrapping_sub ( parameters. d ) . wrapping_add ( 1 ) ) ;
1176- if dict. is_null ( ) || freqs . is_null ( ) {
1172+ if dict. is_null ( ) {
11771173 if displayLevel >= 1 {
11781174 eprintln ! ( "Failed to allocate buffers: out of memory" ) ;
11791175 }
11801176 } else {
1181- memcpy (
1182- freqs as * mut core:: ffi:: c_void ,
1183- ( * ctx) . freqs . as_ptr ( ) as * const core:: ffi:: c_void ,
1184- ( suffixSize) . wrapping_mul ( :: core:: mem:: size_of :: < u32 > ( ) ) ,
1185- ) ;
11861177 let tail = COVER_buildDictionary (
11871178 ctx,
1188- freqs,
1179+ freqs. as_mut_ptr ( ) ,
11891180 & mut activeDmers,
11901181 dict as * mut core:: ffi:: c_void ,
11911182 dictBufferCapacity,
@@ -1213,8 +1204,9 @@ unsafe fn COVER_tryParameters(opaque: *mut core::ffi::c_void) {
12131204 free ( data as * mut core:: ffi:: c_void ) ;
12141205 COVER_map_destroy ( & mut activeDmers) ;
12151206 COVER_dictSelectionFree ( selection) ;
1216- free ( freqs as * mut core :: ffi :: c_void ) ;
1207+ drop ( freqs) ;
12171208}
1209+
12181210#[ cfg_attr( feature = "export-symbols" , export_name = crate :: prefix!( ZDICT_optimizeTrainFromBuffer_cover ) ) ]
12191211pub unsafe extern "C" fn ZDICT_optimizeTrainFromBuffer_cover (
12201212 dictBuffer : * mut core:: ffi:: c_void ,
0 commit comments