Skip to content

Commit 85ee9ad

Browse files
author
luke
committed
Add VECTOR_PTR_RO for consistency with STRING_PTR_RO.
git-svn-id: https://svn.r-project.org/R/trunk@86694 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 5bc6017 commit 85ee9ad

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/include/Defn.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ typedef union { VECTOR_SEXPREC s; double align; } SEXPREC_ALIGN;
425425
#define COMPLEX_RO(x) ((const Rcomplex *) DATAPTR_RO(x))
426426
#define REAL_RO(x) ((const double *) DATAPTR_RO(x))
427427
#define STRING_PTR_RO(x)((const SEXP *) DATAPTR_RO(x))
428+
#define VECTOR_PTR_RO(x)((const SEXP *) DATAPTR_RO(x))
428429

429430
/* List Access Macros */
430431
/* These also work for ... objects */

src/include/Rinternals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ void SET_STRING_ELT(SEXP x, R_xlen_t i, SEXP v);
292292
SEXP SET_VECTOR_ELT(SEXP x, R_xlen_t i, SEXP v);
293293
SEXP *(STRING_PTR)(SEXP x);
294294
const SEXP *(STRING_PTR_RO)(SEXP x);
295+
const SEXP *(VECTOR_PTR_RO)(SEXP x);
295296
NORET SEXP * (VECTOR_PTR)(SEXP x);
296297

297298
R_xlen_t INTEGER_GET_REGION(SEXP sx, R_xlen_t i, R_xlen_t n, int *buf);

src/main/memory.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4216,6 +4216,14 @@ NORET SEXP * (VECTOR_PTR)(SEXP x)
42164216
error(_("not safe to return vector pointer"));
42174217
}
42184218

4219+
const SEXP *(VECTOR_PTR_RO)(SEXP x) {
4220+
if(TYPEOF(x) != VECSXP)
4221+
error("%s() can only be applied to a '%s', not a '%s'",
4222+
"STRING_PTR_RO", "list", R_typeToChar(x));
4223+
CHKZLN(x);
4224+
return VECTOR_PTR_RO(x);
4225+
}
4226+
42194227
void (SET_STRING_ELT)(SEXP x, R_xlen_t i, SEXP v) {
42204228
if(TYPEOF(CHK(x)) != STRSXP)
42214229
error("%s() can only be applied to a '%s', not a '%s'",

0 commit comments

Comments
 (0)