pub unsafe fn ensure_materialized(sexp: SEXP) -> SEXPExpand description
If sexp is ALTREP, force materialization and return the SEXP.
If not ALTREP, return as-is (no-op).
This is the main entry point for ensuring a SEXP is safe to access from non-R threads. After materialization, the data pointer is stable and the SEXP can be freely sent across threads.
Called automatically by TryFromSexp for SEXP — you only need to call
this directly in extern "C-unwind" functions that receive raw SEXPs.
For contiguous types (INTSXP, REALSXP, LGLSXP, RAWSXP, CPLXSXP),
calls DATAPTR_RO to trigger materialization. For STRSXP, iterates
STRING_ELT to force each element to materialize.
§Safety
Must be called on the R main thread (materialization invokes R internals).