Skip to content
Prev 45478 / 63421 Next

Timing of SET_VECTOR_ELT

On Apr 1, 2013, at 1:10 PM, Terry Therneau wrote:

            
You're assigning a pointer, so it doesn't matter.

FWIW, you can avoid all the PROTECTion mess if you alloc+assign, e.g.

SEXP rlist = PROTECT(mknamed(VECSXP, outnames));
SEXP means = SET_VECTOR_ELT(rlist, 0, allocVector(REALSXP, nvar));
...

since you only need to protect the parent object.

Cheers,
Simon