summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2020-04-05 14:22:59 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2020-04-05 14:22:59 +0200
commitfff906a78ba545e77d087a82711b30bcc8e0d0c5 (patch)
tree27b6fef7478e694518b739e6c75692d41fe83f16 /src/main.rs
parentde9bc974a6b423b7f086af23e50c47a097dcd352 (diff)
downloadneco-fff906a78ba545e77d087a82711b30bcc8e0d0c5.tar
neco-fff906a78ba545e77d087a82711b30bcc8e0d0c5.zip
Introduce SafePtr trait, cleanup
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs
index 944b7ab..c79f1da 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,17 +9,26 @@ use core::fmt::Write;
#[no_mangle]
pub extern "C" fn main(_nargs: libc::c_int, _args: *const *const libc::c_char) -> libc::c_int {
let mut stdout = unsafe { libc::stdio::stdout() };
- let x = libc::string::CString::from("foo");
- let l = x.len();
- let y = x.into_raw();
- let z = unsafe {
- libc::boxed::CBox::slice_from_raw_parts(y, l)
- };
- let foo = cstr!("Foo!\n");
- stdout.puts(foo);
- let _ = writeln!(stdout, "Foo: {} {} {}", z[0], z[1], z[2]);
- let b = libc::boxed::CBox::new(42);
- let _ = writeln!(stdout, "Bar: {}", b);
+
+ {
+ let foo = cstr!("Foo!\n");
+ stdout.puts(foo);
+ }
+
+ {
+ let x = libc::string::CString::from("foo");
+ let l = x.len();
+ let y = x.into_raw();
+ let z = unsafe {
+ libc::boxed::CBox::slice_from_raw_parts(y, l)
+ };
+ let _ = writeln!(stdout, "Foo: {} {} {}", z[0], z[1], z[2]);
+ }
+
+ {
+ let b = libc::boxed::CBox::new(42);
+ let _ = writeln!(stdout, "Bar: {}", b);
+ }
0
}