Skip to content

Commit

Permalink
yet more
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlie Davis committed Jun 6, 2024
1 parent efb0b1c commit af9a466
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crates/libs/core/src/array.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use core::mem::size_of;

/// A WinRT array stores elements contiguously in a heap-allocated buffer.
pub struct Array<T: Type<T>> {
Expand All @@ -25,7 +26,7 @@ impl<T: Type<T>> Array<T> {
pub fn with_len(len: usize) -> Self {
assert!(len < u32::MAX as usize);
let bytes_amount = len
.checked_mul(core::mem::size_of::<T>())
.checked_mul(size_of::<T>())
.expect("Attempted to allocate too large an Array");

// WinRT arrays must be allocated with CoTaskMemAlloc.
Expand Down
3 changes: 2 additions & 1 deletion crates/libs/core/src/strings/hstring.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::*;
use core::mem::size_of;

/// A WinRT string ([HSTRING](https://docs.microsoft.com/en-us/windows/win32/winrt/hstring))
/// is reference-counted and immutable.
Expand Down Expand Up @@ -426,7 +427,7 @@ impl Header {
debug_assert!(len != 0);
// Allocate enough space for header and two bytes per character.
// The space for the terminating null character is already accounted for inside of `Header`.
let alloc_size = core::mem::size_of::<Header>() + 2 * len as usize;
let alloc_size = size_of::<Header>() + 2 * len as usize;

let header = imp::heap_alloc(alloc_size)? as *mut Header;

Expand Down

0 comments on commit af9a466

Please sign in to comment.