In my Rust code I have to use some C function in the Rust side. In that function I have to pass some structures as example.
#[repr(C)]
pub structA {
pub buffer:[i8; 8000],
pub writing: i32,
pub written_num: i32,
pub write_index: i32,
pub id: i32,
pub sortArray: StructB,
}
FFI calling part
let mut struc_a = Box::new(structA::new());
unsafe {
ProcessStrucA(&mut *structA);
}
structure in C side
typedef struct {
char buffer[8000];
size_t writing;
size_t written_num;
size_t write_index;
int id;
StructB structB;
} structA;
When I'm passing above structure to C side it will not get the values which we send from the Rust side. According to my understanding this could be happening due to invalid memory handling. How do I resolve this issue?