Update to new alloc API

This commit is contained in:
Jeremy Soller
2018-06-19 17:44:51 -06:00
parent 63b5755aee
commit 8a52c84f1a
2 changed files with 3 additions and 6 deletions
+3 -4
View File
@@ -1,8 +1,7 @@
#[cfg(feature="rusttype")]
extern crate rusttype;
use alloc::allocator::{Alloc, Layout};
use alloc::heap::Global;
use std::alloc::{Alloc, Global, Layout};
use std::{cmp, slice};
use std::ptr::NonNull;
@@ -108,7 +107,7 @@ impl Display {
let onscreen = self.onscreen.as_mut_ptr();
self.onscreen = unsafe { slice::from_raw_parts_mut(onscreen, size) };
unsafe { Global.dealloc(NonNull::new_unchecked(self.offscreen.as_mut_ptr() as *mut u8).as_opaque(), Layout::from_size_align_unchecked(self.offscreen.len() * 4, 4096)) };
unsafe { Global.dealloc(NonNull::new_unchecked(self.offscreen.as_mut_ptr() as *mut u8), Layout::from_size_align_unchecked(self.offscreen.len() * 4, 4096)) };
self.offscreen = unsafe { slice::from_raw_parts_mut(offscreen as *mut u32, size) };
} else {
println!("Display is already {}, {}", width, height);
@@ -277,6 +276,6 @@ impl Display {
impl Drop for Display {
fn drop(&mut self) {
unsafe { Global.dealloc(NonNull::new_unchecked(self.offscreen.as_mut_ptr() as *mut u8).as_opaque(), Layout::from_size_align_unchecked(self.offscreen.len() * 4, 4096)) };
unsafe { Global.dealloc(NonNull::new_unchecked(self.offscreen.as_mut_ptr() as *mut u8), Layout::from_size_align_unchecked(self.offscreen.len() * 4, 4096)) };
}
}
-2
View File
@@ -1,9 +1,7 @@
#![deny(warnings)]
#![feature(alloc)]
#![feature(allocator_api)]
#![feature(asm)]
extern crate alloc;
extern crate orbclient;
extern crate syscall;