| 239 | |
| 240 | template <typename T> |
| 241 | void r6_reset_pointer(SEXP r6) { |
| 242 | // R_UnboundValue and Rf_findVarInFrame are non-API as of R 4.6 |
| 243 | #if R_VERSION >= R_Version(4, 6, 0) |
| 244 | if (!R_existsVarInFrame(r6, arrow::r::symbols::xp)) { |
| 245 | return; |
| 246 | } |
| 247 | SEXP xp = R_getVar(arrow::r::symbols::xp, r6, FALSE); |
| 248 | #elif R_VERSION >= R_Version(4, 5, 0) |
| 249 | SEXP xp = R_getVarEx(arrow::r::symbols::xp, r6, FALSE, R_UnboundValue); |
| 250 | #else |
| 251 | SEXP xp = Rf_findVarInFrame(r6, arrow::r::symbols::xp); |
| 252 | #endif |
| 253 | void* p = R_ExternalPtrAddr(xp); |
| 254 | if (p != nullptr) { |
| 255 | delete reinterpret_cast<const std::shared_ptr<T>*>(p); |
| 256 | R_SetExternalPtrAddr(xp, nullptr); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | // T is either std::shared_ptr<U> or std::unique_ptr<U> |
| 261 | // e.g. T = std::shared_ptr<arrow::Array> |
nothing calls this directly
no outgoing calls
no test coverage detected