Part 1: A Deep Dive into Rust and C Memory Interoperability
“Memory oppresses me.” - Severian, The Book of the New Sun
Interviewer: “What happens if you allocate memory with C’s malloc and try to free it with Rust’s dealloc, if you get a pointer to the memory from C?”
Me: “If we do it via FFI then there’s a possibility the program may continue working (because the underlying structs share the same memory layout? right? …right?)”
Now if you have any experience working with memory management, you know that this is a dangerous answer. But I didn’t know it a...
Read more at notashes.me