diff --git a/pco_c/include/cpcodec_generated.h b/pco_c/include/cpcodec_generated.h index 4c8d45a9..7d6469f2 100644 --- a/pco_c/include/cpcodec_generated.h +++ b/pco_c/include/cpcodec_generated.h @@ -7,18 +7,18 @@ typedef enum PcoError { typedef struct PcoFfiVec { const void *ptr; - unsigned int len; + size_t len; const void *raw_box; } PcoFfiVec; enum PcoError pco_simpler_compress(const void *nums, - unsigned int len, + size_t len, unsigned char dtype, unsigned int level, struct PcoFfiVec *dst); enum PcoError pco_simple_decompress(const void *compressed, - unsigned int len, + size_t len, unsigned char dtype, struct PcoFfiVec *dst); diff --git a/pco_c/src/lib.rs b/pco_c/src/lib.rs index 265aa0be..7828a7fa 100644 --- a/pco_c/src/lib.rs +++ b/pco_c/src/lib.rs @@ -2,7 +2,7 @@ use std::ptr; -use libc::{c_uchar, c_uint, c_void}; +use libc::{c_uchar, c_uint, c_void, size_t}; use pco::data_types::{CoreDataType, NumberLike}; @@ -51,7 +51,7 @@ pco::with_core_dtypes!(impl_dtypes); #[repr(C)] pub struct PcoFfiVec { ptr: *const c_void, - len: c_uint, + len: size_t, raw_box: *const c_void, } @@ -61,7 +61,7 @@ impl PcoFfiVec { Vec: Into, { self.ptr = v.as_ptr() as *const c_void; - self.len = v.len() as c_uint; + self.len = v.len(); self.raw_box = Box::into_raw(Box::new(v.into())) as *const c_void; } @@ -79,11 +79,11 @@ impl PcoFfiVec { fn _simpler_compress( nums: *const c_void, - len: c_uint, + len: size_t, level: c_uint, ffi_vec_ptr: *mut PcoFfiVec, ) -> PcoError { - let slice = unsafe { std::slice::from_raw_parts(nums as *const T, len as usize) }; + let slice = unsafe { std::slice::from_raw_parts(nums as *const T, len) }; match pco::standalone::simpler_compress(slice, level as usize) { Err(_) => PcoError::PcoCompressionError, Ok(v) => { @@ -95,13 +95,13 @@ fn _simpler_compress( fn _simple_decompress( compressed: *const c_void, - len: c_uint, + len: size_t, ffi_vec_ptr: *mut PcoFfiVec, ) -> PcoError where Vec: Into, { - let slice = unsafe { std::slice::from_raw_parts(compressed as *const u8, len as usize) }; + let slice = unsafe { std::slice::from_raw_parts(compressed as *const u8, len) }; match pco::standalone::simple_decompress::(slice) { Err(_) => PcoError::PcoDecompressionError, Ok(v) => { @@ -114,7 +114,7 @@ where #[no_mangle] pub extern "C" fn pco_simpler_compress( nums: *const c_void, - len: c_uint, + len: size_t, dtype: c_uchar, level: c_uint, dst: *mut PcoFfiVec, @@ -133,7 +133,7 @@ pub extern "C" fn pco_simpler_compress( #[no_mangle] pub extern "C" fn pco_simple_decompress( compressed: *const c_void, - len: c_uint, + len: size_t, dtype: c_uchar, dst: *mut PcoFfiVec, ) -> PcoError {