Skip to content

Commit

Permalink
localize the unsafety, like a good rust citizen
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Somerville committed Apr 14, 2014
1 parent 308c1ff commit 5ab2e7c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ fn range(lo: uint, hi: uint, it: |uint| -> ()) {
}
}

unsafe fn clear_screen(background: Color) {
fn clear_screen(background: Color) {
range(0, 80*25, |i| {
*((0xb8000 + i * 2) as *mut u16) = (background as u16) << 12;
unsafe {
*((0xb8000 + i * 2) as *mut u16) = (background as u16) << 12;
}
});
}

#[no_mangle]
#[no_split_stack]
pub unsafe fn main() {
pub fn main() {
clear_screen(LightRed);
}

0 comments on commit 5ab2e7c

Please sign in to comment.