Skip to content
Prev 3893 / 63421 Next

Documentatio: typo in Writing R Extensions (PR#557)

stephen@anc.ed.ac.uk writes:
Yup. Already fixed in the development version.

Actually "SEXP pointer" is a bit like "ATM machine". SEXPs are
pointers to SEXPREC, so is a SEXP pointer a (SEXPREC **) ? Besides,
one is not protecting the pointer but the object it points to (by
putting a pointer to it on the protection stack). This is
a common misconception:

 PROTECT(p);
 ...
 p = AllocSexp(....);

will not protect the new value of p. You need

 PROTECT(p);
 ...
 UNPROTECT(1);
 PROTECT(p = AllocSexp(....));

Hmm. Looks like the whole section needs going over. The stuff about
"ensuring that the pointer is updated" is bogus too (it is VECRECs
that move, not SEXPRECs). And the description of UNPROTECT_PTR is
vacuous at best.