#[unsafe(no_mangle)]pub extern "C" fn nstd_cstring_new_with_cap(
allocator: &NSTDAllocator,
cap: NSTDUInt,
) -> NSTDOptionalCString<'_>Available on crate feature
cstring only.Expand description
Creates a new NSTDCString initialized with the given capacity.
§Parameters:
-
const NSTDAllocator *allocator- The memory allocator. -
NSTDUInt cap- The number of bytes to allocate ahead of time.
§Returns
NSTDOptionalCString cstring - The new C string on success, or an uninitialized “none” variant
if allocating fails.
§Example
use nstd_sys::{alloc::NSTD_ALLOCATOR, cstring::nstd_cstring_new_with_cap};
let cstring = unsafe { nstd_cstring_new_with_cap(&NSTD_ALLOCATOR, 10) };