On Thu, Jun 6, 2013 at 12:44 PM, Abhijeet Gaiha <[email protected]> wrote: > This suggests that any data allocated in C libs (including statics) is > basically part of a "global" address space available to all tasks in a Rust > program. Is that correct? > Is there as equivalent of malloc() for Rust as well?
It's not available to all tasks any more than unique/managed allocations, because that would be unsafe. All memory in the process is globally accessible by unsafe code - whether it's a stack allocation or a heap allocation. Providing a safe interface for a C library involves wrapping any resources it returns with destructors, which makes the objects movable/non-implicitly-copyable like unique pointers. Copying these types has to be forbidden (as with sockets/files), produce an unrelated deep copy (like unique pointers/vectors) or they have to be task-local (via #[non_owned]) if they use reference counting. _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
