Skip to main content

alloc_r_vector

Function alloc_r_vector 

Source
pub(crate) unsafe fn alloc_r_vector<T: RNativeType>(
    n: usize,
) -> (SEXP, &'static mut [T])
Expand description

Allocate an R vector of type T with n elements and return (SEXP, &mut [T]).

The returned SEXP is unprotected — caller must protect via Rf_protect, OwnedProtect, or ProtectScope before any further R allocation.

§Safety

Must be called from R’s main thread.