From 547562b793a99c92594db2d415408f0d0d98cd79 Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Tue, 17 Mar 2026 09:40:12 +0000 Subject: [PATCH 1/2] Remove dead code from earlier R versions --- r/src/arrow_cpp11.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index 6ea11ea008da..ecc069171c89 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -38,17 +38,6 @@ #define ARROW_R_DCHECK(EXPR) #endif -#if (R_VERSION < R_Version(3, 5, 0)) -#define LOGICAL_RO(x) ((const int*)LOGICAL(x)) -#define INTEGER_RO(x) ((const int*)INTEGER(x)) -#define REAL_RO(x) ((const double*)REAL(x)) -#define COMPLEX_RO(x) ((const Rcomplex*)COMPLEX(x)) -#define STRING_PTR_RO(x) ((const SEXP*)STRING_PTR(x)) -#define RAW_RO(x) ((const Rbyte*)RAW(x)) -#define DATAPTR_RO(x) ((const void*)STRING_PTR(x)) -#define DATAPTR(x) (void*)STRING_PTR(x) -#endif - // R_altrep_class_name and R_altrep_class_package don't exist before R 4.6 #if R_VERSION < R_Version(4, 6, 0) inline SEXP R_altrep_class_name(SEXP x) { From 2e1f1df5ec93ee36f71dcb51c16c05310d827764 Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Tue, 17 Mar 2026 09:51:28 +0000 Subject: [PATCH 2/2] fix usage of Rf_findVarInFrame --- r/src/arrow_cpp11.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index ecc069171c89..d28ad0feded2 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -208,8 +208,12 @@ Pointer r6_to_pointer(SEXP self) { cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str()); } +#if R_VERSION >= R_Version(4, 5, 0) + SEXP xp = R_getVarEx(arrow::r::symbols::xp, self, FALSE, R_UnboundValue); +#else SEXP xp = Rf_findVarInFrame(self, arrow::r::symbols::xp); - if (xp == R_NilValue) { +#endif + if (xp == R_UnboundValue || xp == R_NilValue) { cpp11::stop("Invalid: self$`.:xp:.` is NULL"); } @@ -223,7 +227,11 @@ Pointer r6_to_pointer(SEXP self) { template void r6_reset_pointer(SEXP r6) { +#if R_VERSION >= R_Version(4, 5, 0) + SEXP xp = R_getVarEx(arrow::r::symbols::xp, r6, FALSE, R_UnboundValue); +#else SEXP xp = Rf_findVarInFrame(r6, arrow::r::symbols::xp); +#endif void* p = R_ExternalPtrAddr(xp); if (p != nullptr) { delete reinterpret_cast*>(p);