@@ -5020,7 +5020,7 @@ R_xlen_t R_maxLength(SEXP x)
50205020 return GROWABLE_BIT_SET (x ) ? XTRUELENGTH (x ) : xlength (x );
50215021}
50225022
5023- SEXP R_allocResizableVector (SEXPTYPE type , R_xlen_t len , R_xlen_t maxlen )
5023+ SEXP R_allocResizableVector (SEXPTYPE type , R_xlen_t maxlen )
50245024{
50255025 switch (type ) {
50265026 case LGLSXP :
@@ -5036,12 +5036,9 @@ SEXP R_allocResizableVector(SEXPTYPE type, R_xlen_t len, R_xlen_t maxlen)
50365036 error (_ ("cannot make a resizable vector of type '%s'" ),
50375037 sexptype2char (type ));
50385038 }
5039- if (len > maxlen )
5040- error (_ ("len larger than maxlen" ));
50415039 SEXP val = allocVector (type , maxlen );
50425040 SET_TRUELENGTH (val , maxlen );
50435041 SET_GROWABLE_BIT (val );
5044- SETLENGTH (val , len );
50455042 return val ;
50465043}
50475044
@@ -5081,19 +5078,14 @@ void R_resizeVector(SEXP x, R_xlen_t newlen)
50815078 error (_ ("not a resizable vector" ));
50825079 if (newlen > XTRUELENGTH (x ))
50835080 error (_ ("'newlen' is too large" ));
5084- if (MAYBE_SHARED (x ))
5085- error (_ ("can't resize a vector that might be shared" ));
50865081 if (ATTRIB (x ) != R_NilValue ) {
5082+ // clear length-dependent attributes
50875083 if (getAttrib (x , R_DimSymbol ) != R_NilValue )
5088- error ( _ ( "can't resize a vector with a 'dim' attribute" ) );
5084+ setAttrib ( x , R_DimSymbol , R_NilValue );
50895085 if (getAttrib (x , R_DimNamesSymbol ) != R_NilValue )
5090- error (_ ("can't resize a vector with a 'dimnames' attribute" ));
5091- SEXP names = getAttrib (x , R_NamesSymbol );
5092- if (names != R_NilValue ) {
5093- if (MAYBE_SHARED (names ))
5094- error (_ ("can't resize 'names' that might be shared" ));
5095- R_resizeVector (names , newlen );
5096- }
5086+ setAttrib (x , R_DimNamesSymbol , R_NilValue );
5087+ if (getAttrib (x , R_NamesSymbol ) != R_NilValue )
5088+ setAttrib (x , R_NamesSymbol , R_NilValue );
50975089 }
50985090 R_xlen_t len = XLENGTH (x );
50995091 if (newlen < len ) // clear dropped elements to drop refcounts
0 commit comments