I am having one c api which i need to call from rust side
int Convert(char *inputData, unsigned int nDataLen, char * outputData, unsigned int nOutLen);
We pass data to be converted to inputData
arr and get output on OutputData
arr. The nDataLen
and nOutLen
are the size of input and output arr respectively.
The size of inputData and OutputData can only be 5000 bytes long at a time.
The inputData is opus encoded audio I get from azure api.
I am using bindgen and it generated the following binding
extern "C" {
pub fn Convert(
inputData: *mut ::std::os::raw::c_char,
nDataLen: ::std::os::raw::c_uint,
outputData: *mut ::std::os::raw::c_char,
nOutLen: ::std::os::raw::c_uint,
) -> ::std::os::raw::c_int;
}
I am trying to test this code using following
let mut input_data: Vec<u8> = read_data.unwrap();
let mut truncated_data = &input_data[0..5000];
let input_len = input_data.len() as u32;
let mut output_data = vec![0i8; 5000];
let output_len = 5000;
let result = Convert(
truncated_data.as_ptr() as *mut i8,
input_len,
output_data.as_mut_ptr(),
output_len,
);
I am getting SIGSEGV: invalid memory reference
while trying to use the above code. Can someone please help