alloc_zeroed_memory

Function alloc_zeroed_memory 

Source
pub fn alloc_zeroed_memory<C: Memorable>(size: usize) -> MemoryBuffer<C>
Expand description

Allocate a new memory buffer with the given size.

The size is the number of elements to allocate in the memory buffer, not the number of bytes. The memory buffer is aligned to cachelines, and the elements will be zeroed.

§Type Parameters

  • C: The faer entity type for the memory buffer.

§Arguments

  • size - The number of elements to allocate in the memory buffer.

§Returns

A new memory buffer with the given size.

§Panics

This function will panic if the memory requirement overflows isize.

§Example

use qudit_core::memory::alloc_zeroed_memory;
let size = 10;
let mem = alloc_zeroed_memory::<f32>(size);
assert_eq!(mem.len(), size);

§See Also

  • MemoryBuffer type alias for more information on memory buffers.