nstd_core_ptr_align

Function nstd_core_ptr_align 

Source
#[unsafe(no_mangle)]
pub const extern "C" fn nstd_core_ptr_align(ptr: &NSTDPtr) -> NSTDUInt
Available on crate feature core only.
Expand description

Returns the alignment of the object being pointed to.

§Parameters:

  • const NSTDPtr *ptr - The pointer.

§Returns

NSTDUInt align - The alignment of the object pointed to by ptr.

§Examples

use core::ptr::addr_of;
use nstd_sys::core::ptr::{nstd_core_ptr_align, nstd_core_ptr_new};

unsafe {
    const SIZE: usize = core::mem::size_of::<[u8; 32]>();
    const ALIGN: usize = core::mem::align_of::<[u8; 32]>();
    let x = [33u8; 32];
    let ptr = nstd_core_ptr_new(addr_of!(x).cast(), SIZE, ALIGN).unwrap();
    assert!(nstd_core_ptr_align(&ptr) == ALIGN);
}