Skip to content
Snippets Groups Projects
Commit ccbd8580 authored by Deepak Sirone's avatar Deepak Sirone
Browse files

Fix compilation error for graphical_debug

parent 145785e2
No related branches found
No related tags found
1 merge request!91Fix compilation error for graphical_debug
use alloc::allocator::{Alloc, Layout}; use alloc::allocator::{Alloc, Layout};
use alloc::heap::Heap; use alloc::heap::Heap;
use core::{cmp, slice}; use core::{cmp, slice};
use core::ptr::NonNull;
use super::FONT; use super::FONT;
use super::primitive::{fast_set32, fast_set64, fast_copy}; use super::primitive::{fast_set32, fast_set64, fast_copy};
...@@ -16,7 +17,7 @@ pub struct Display { ...@@ -16,7 +17,7 @@ pub struct Display {
impl Display { impl Display {
pub fn new(width: usize, height: usize, onscreen: usize) -> Display { pub fn new(width: usize, height: usize, onscreen: usize) -> Display {
let size = width * height; let size = width * height;
let offscreen = unsafe { Heap.alloc(Layout::from_size_align_unchecked(size * 4, 4096)).unwrap() }; let offscreen = unsafe { Heap.alloc(Layout::from_size_align_unchecked(size * 4, 4096)).unwrap().as_ptr() };
unsafe { fast_set64(offscreen as *mut u64, 0, size/2) }; unsafe { fast_set64(offscreen as *mut u64, 0, size/2) };
Display { Display {
width: width, width: width,
...@@ -145,6 +146,6 @@ impl Display { ...@@ -145,6 +146,6 @@ impl Display {
impl Drop for Display { impl Drop for Display {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { Heap.dealloc(self.offscreen.as_mut_ptr() as *mut u8, Layout::from_size_align_unchecked(self.offscreen.len() * 4, 4096)) }; unsafe { Heap.dealloc(NonNull::new(self.offscreen.as_mut_ptr()).unwrap().as_opaque(), Layout::from_size_align_unchecked(self.offscreen.len() * 4, 4096)) };
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment