Skip to content

Commit a758ca8

Browse files
misc(rendy): wrap queue character ptr in NonNull
Signed-off-by: Anhad Singh <[email protected]>
1 parent fc41560 commit a758ca8

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/aero_kernel/src/rendy.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use core::fmt::Write;
1919

2020
use core::ops::{Index, IndexMut};
21+
use core::ptr::NonNull;
2122
use core::time::Duration;
2223
use core::{fmt, u8};
2324

@@ -294,7 +295,7 @@ pub struct Inner<'this> {
294295

295296
queue: Box<[QueueCharacter]>,
296297
grid: Box<[Character]>,
297-
map: Box<[Option<*mut QueueCharacter>]>,
298+
map: Box<[Option<NonNull<QueueCharacter>>]>,
298299
bg_canvas: Box<[u32]>,
299300

300301
queue_cursor: usize,
@@ -496,13 +497,13 @@ impl<'a> Inner<'a> {
496497
queue.x = x;
497498
queue.y = y;
498499

499-
self.map[i] = Some(queue as *mut _);
500+
self.map[i] = Some(NonNull::from(queue));
500501
}
501502

502503
let item = self.map[i];
503504

504505
unsafe {
505-
(*item.unwrap()).char = *char;
506+
item.unwrap().as_mut().char = *char;
506507
}
507508
}
508509

@@ -529,7 +530,7 @@ impl<'a> Inner<'a> {
529530

530531
if self.map[i].is_some() {
531532
unsafe {
532-
char = (*self.map[i].unwrap()).char;
533+
char = self.map[i].unwrap().as_ref().char;
533534
}
534535
} else {
535536
char = self.grid[i];
@@ -541,7 +542,7 @@ impl<'a> Inner<'a> {
541542

542543
if self.map[i].is_some() {
543544
unsafe {
544-
self.grid[i] = (*self.map[i].unwrap()).char;
545+
self.grid[i] = self.map[i].unwrap().as_ref().char;
545546
}
546547

547548
self.map[i] = None;
@@ -686,7 +687,7 @@ impl<'a> Inner<'a> {
686687

687688
if let Some(char) = queue {
688689
unsafe {
689-
res = (*char).char;
690+
res = char.as_ref().char;
690691
}
691692
} else {
692693
res = self.grid[i];
@@ -740,7 +741,7 @@ impl<'this> DebugRendy<'this> {
740741

741742
let grid = mem::alloc_boxed_buffer::<Character>(rows * cols);
742743
let queue = mem::alloc_boxed_buffer::<QueueCharacter>(rows * cols);
743-
let map = mem::alloc_boxed_buffer::<Option<*mut QueueCharacter>>(rows * cols);
744+
let map = mem::alloc_boxed_buffer::<Option<NonNull<QueueCharacter>>>(rows * cols);
744745
let bg_canvas = mem::alloc_boxed_buffer::<u32>(width * height);
745746

746747
let mut this = Self {

0 commit comments

Comments
 (0)