LVGL handles zero sized
This commit is contained in:
parent
3e7e056da6
commit
e3fd8d5736
1 changed files with 1 additions and 3 deletions
|
@ -7,13 +7,11 @@ pub(crate) struct Box<T>(NonNull<T>);
|
||||||
|
|
||||||
impl<T> Box<T> {
|
impl<T> Box<T> {
|
||||||
pub fn new(inner: T) -> LvResult<Box<T>> {
|
pub fn new(inner: T) -> LvResult<Box<T>> {
|
||||||
assert_ne!(mem::size_of::<T>(), 0, "We don't handle ZSTs");
|
|
||||||
|
|
||||||
let size = mem::size_of::<T>();
|
let size = mem::size_of::<T>();
|
||||||
let inner = unsafe {
|
let inner = unsafe {
|
||||||
// LVGL already aligns the memory address for us
|
|
||||||
let ptr = lvgl_sys::lv_mem_alloc(size as lvgl_sys::size_t) as *mut T;
|
let ptr = lvgl_sys::lv_mem_alloc(size as lvgl_sys::size_t) as *mut T;
|
||||||
|
|
||||||
|
// LVGL should align the memory address for us!
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ptr as usize % mem::align_of::<T>(),
|
ptr as usize % mem::align_of::<T>(),
|
||||||
0,
|
0,
|
||||||
|
|
Loading…
Reference in a new issue