A deep dive into Rust and C memory interoperability
1–10 of 84 posts
Re: A deep dive into Rust and C memory interoperability
#2Re: A deep dive into Rust and C memory interoperability
#3Re: A deep dive into Rust and C memory interoperability
#4Section named "The Interview Question That Started Everything" doesn't contain the interview question.
> 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?)”
Re: A deep dive into Rust and C memory interoperability
#5Re: A deep dive into Rust and C memory interoperability
#6Re: A deep dive into Rust and C memory interoperability
#7Something I'd like to know for mixing Rust and C. I know it's possible to access a struct from both C and Rust code and have seen examples. But those all use accessor functions on the Rust side rather than accessing the members directly. Is it possible to define a structure in one of the languages and then via some wrapper or definitions be able to access it idiomatically in the other language? Can you point to some…
Re: A deep dive into Rust and C memory interoperability
#8One of the areas I wonder about this a lot is when integrating Rust code into Postgres which has its own allocator system. Mostly right now when we need to have complex data structures (non-Postgres data structures) that must live outside of the lexical scope we put them somewhere global and return a handle to the C code to reference the object. But with the upcoming support for passing an allocator to any data struc…
It’s also very possible I’m missing something!
Re: A deep dive into Rust and C memory interoperability
#9Something I'd like to know for mixing Rust and C. I know it's possible to access a struct from both C and Rust code and have seen examples. But those all use accessor functions on the Rust side rather than accessing the members directly. Is it possible to define a structure in one of the languages and then via some wrapper or definitions be able to access it idiomatically in the other language? Can you point to some…
Re: A deep dive into Rust and C memory interoperability
#10One of the areas I wonder about this a lot is when integrating Rust code into Postgres which has its own allocator system. Mostly right now when we need to have complex data structures (non-Postgres data structures) that must live outside of the lexical scope we put them somewhere global and return a handle to the C code to reference the object. But with the upcoming support for passing an allocator to any data struc…
I’m not sure what those two things have to do with each other, though I did just wake up. The only thing the new allocator stuff would give you is the ability to allocate a standard library data structure with the Postgres allocator. Scoping and handles and such wouldn’t change, and using your own data structures wouldn’t change. It’s also very possible I’m missing something!
Yeah no this is basically all I'm saying. I'm excited for this.