Skip to content

Commit 812ec6a

Browse files
committed
Update FFI example
- Use meaningful names - Clarify comments - Fix C function declaration
1 parent aea9423 commit 812ec6a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/liballoc/boxed.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,21 @@
6868
//!
6969
//! ```c
7070
//! /* C header */
71-
//! struct Foo* foo(); /* Returns ownership */
72-
//! void bar(struct Foo*); /* `bar` takes ownership */
71+
//! struct Foo* foo_new(void); /* Returns ownership to the caller */
72+
//! void foo_delete(struct Foo*); /* Takes ownership from the caller */
7373
//! ```
7474
//!
7575
//! ```
7676
//! #[repr(C)]
7777
//! pub struct Foo;
7878
//!
7979
//! #[no_mangle]
80-
//! pub extern "C" fn foo() -> Box<Foo> {
80+
//! pub extern "C" fn foo_new() -> Box<Foo> {
8181
//! Box::new(Foo)
8282
//! }
8383
//!
8484
//! #[no_mangle]
85-
//! pub extern "C" fn bar(_: Option<Box<Foo>>) {}
85+
//! pub extern "C" fn foo_delete(_: Option<Box<Foo>>) {}
8686
//! ```
8787
//!
8888
//! [dereferencing]: ../../std/ops/trait.Deref.html

0 commit comments

Comments
 (0)