immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.79k stars 219 forks source link

(`c2rust-analyze`) Support custom deallocators/linear `Box` types #1007

Open kkysen opened 11 months ago

kkysen commented 11 months ago

For custom allocator/deallocator functions other than {m,c,re}alloc and free, such as:

it would be nice to also support them like we do for the primary allocators/deallocator. As @spernsteiner said,

maybe we could handle this with an additional permission or flag that translates into a custom "linear (non-affine) box" type that must be explicitly freed with a special function (you can't just let it go out of scope).

That said, even if we don't track them correctly, memory leaks are safe, and we'll be doing the same memory management as was in C. It'd be similar to any other resource as well, like open, etc. and close.