MCPcopy Create free account
hub / github.com/apache/arrow / r6_reset_pointer

Function r6_reset_pointer

r/src/arrow_cpp11.h:241–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239
240template <typename T>
241void 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>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected