the.bay.news

Is there an equivalent for flexible array in rust for FFI talking to C

The Rust Programming Language Forum
Is there an equivalent for flexible array in rust for FFI talking to C
Hi there, I have a question regarding FFI, in C you could have a flexible array inside a struct that is allocated in one memory block. typedef struct { size_t size; char data[]; } my_string; my_string *s = malloc(sizeof(my_string) + len + 1); Is there a way to have similar layout without having two seperate memory block in rust for the data and struct? #[repr(C)] struct my_string { data: *mut u8, // this is fine but another allocated memory block; size: usize, } In the case where C is the...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.