Function nstd_sys::shared_ptr::nstd_shared_ptr_size
source · #[no_mangle]
pub const extern "C" fn nstd_shared_ptr_size(
shared_ptr: &NSTDSharedPtr<'_>
) -> NSTDUInt
Available on crate feature
shared_ptr
only.Expand description
Returns the size of the shared object.
§Parameters:
const NSTDSharedPtr *shared_ptr
- The shared pointer.
§Returns
NSTDUInt size
- The size of the shared object.
§Example
use nstd_sys::{
alloc::NSTD_ALLOCATOR,
core::alloc::nstd_core_alloc_layout_new,
shared_ptr::{nstd_shared_ptr_new_zeroed, nstd_shared_ptr_size},
};
unsafe {
let size = core::mem::size_of::<f64>();
let align = core::mem::align_of::<f64>();
let layout = nstd_core_alloc_layout_new(size, align).unwrap();
let shared_ptr = nstd_shared_ptr_new_zeroed(&NSTD_ALLOCATOR, layout).unwrap();
assert!(nstd_shared_ptr_size(&shared_ptr) == size);
}