11#include "data.table.h"
22
3- #if R_VERSION < R_Version (3 ,4 ,0 ) // not needed with GROWABLE_BIT
43static void finalizer (SEXP p )
54{
65 SEXP x ;
@@ -23,7 +22,6 @@ static void finalizer(SEXP p)
2322 UNPROTECT (1 );
2423 return ;
2524}
26- #endif
2725
2826void setselfref (SEXP x ) {
2927 if (!INHERITS (x , char_datatable )) return ; // #5286
@@ -40,9 +38,6 @@ void setselfref(SEXP x) {
4038 R_NilValue
4139 ))
4240 ));
43- #if R_VERSION < R_Version (3 ,4 ,0 ) // not needed with GROWABLE_BIT
44- R_RegisterCFinalizerEx (p , finalizer , FALSE);
45- #endif
4641 UNPROTECT (2 );
4742
4843/*
@@ -134,20 +129,9 @@ static int _selfrefok(SEXP x, Rboolean checkNames, Rboolean verbose) {
134129 // (1) we allocate the data.table and/or its names, so it has the GROWABLE_BIT set, so copies will have zero TRUELENGTH, or
135130 // (2) someone else creates them from scratch, so (only using the API) will have zero TRUELENGTH.
136131 // We then return false and either re-create the data.table from scratch or signal an error, so the current object having a zero TRUELENGTH is fine.
137- // R < 3.4 doesn't have the GROWABLE_BIT, so let's reset the TRUELENGTH just in case.
138- #if R_VERSION < R_Version (3 ,4 ,0 )
139- if (names != tag && isString (names ))
140- SET_TRUELENGTH (names , LENGTH (names ));
141- // R copied this vector not data.table; it's not actually over-allocated. It looks over-allocated
142- // because R copies the original vector's tl over despite allocating length.
143- #endif
144132 prot = R_ExternalPtrProtected (v );
145133 if (TYPEOF (prot ) != EXTPTRSXP ) // Very rare. Was error(_(".internal.selfref prot is not itself an extptr")).
146134 return 0 ; // # nocov ; see http://stackoverflow.com/questions/15342227/getting-a-random-internal-selfref-error-in-data-table-for-r
147- #if R_VERSION < R_Version (3 ,4 ,0 )
148- if (x != R_ExternalPtrAddr (prot ))
149- SET_TRUELENGTH (x , LENGTH (x )); // R copied this vector not data.table, it's not actually over-allocated
150- #endif
151135 return checkNames ? names == tag : x == R_ExternalPtrAddr (prot );
152136}
153137
0 commit comments