Skip to content

Commit 2b5444b

Browse files
committed
tweak patch update
1 parent cebe420 commit 2b5444b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/assign.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ SEXP alloccol(SEXP dt, R_len_t n, Rboolean verbose)
266266
// added (n>l) ? ... for #970, see test 1481.
267267
// TO DO: test realloc names if selfrefnamesok (users can setattr(x,"name") themselves for example.
268268

269-
tl = growable_max_size(dt);
269+
tl = growable_capacity(dt);
270270
// R <= 2.13.2 and we didn't catch uninitialized tl somehow
271271
if (tl<0) internal_error(__func__, "tl of class is marked but tl<0"); // # nocov
272272
if (tl>0 && tl<l) internal_error(__func__, "tl (%d) < l (%d) but tl of class is marked", tl, l); // # nocov
@@ -316,11 +316,11 @@ SEXP shallowwrapper(SEXP dt, SEXP cols) {
316316
if (!selfrefok(dt, FALSE)) {
317317
int n = isNull(cols) ? length(dt) : length(cols);
318318
return(shallow(dt, cols, n));
319-
} else return(shallow(dt, cols, growable_max_size(dt)));
319+
} else return(shallow(dt, cols, growable_capacity(dt)));
320320
}
321321

322322
SEXP truelength(SEXP x) {
323-
return ScalarInteger(is_growable(x) ? growable_max_size(x) : 0);
323+
return ScalarInteger(is_growable(x) ? growable_capacity(x) : 0);
324324
}
325325

326326
SEXP selfrefokwrapper(SEXP x, SEXP verbose) {
@@ -515,7 +515,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
515515
// modify DT by reference. Other than if new columns are being added and the allocVec() fails with
516516
// out-of-memory. In that case the user will receive hard halt and know to rerun.
517517
if (length(newcolnames)) {
518-
oldtncol = is_growable(dt) ? growable_max_size(dt) : 0; // TO DO: oldtncol can be just called tl now, as we won't realloc here any more.
518+
oldtncol = is_growable(dt) ? growable_capacity(dt) : 0; // TO DO: oldtncol can be just called tl now, as we won't realloc here any more.
519519

520520
if (oldtncol<oldncol) {
521521
if (oldtncol==0) error(_("This data.table has either been loaded from disk (e.g. using readRDS()/load()) or constructed manually (e.g. using structure()). Please run setDT() or setalloccol() on it first (to pre-allocate space for new columns) before assigning by reference to it.")); // #2996
@@ -528,9 +528,9 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
528528
error(_("It appears that at some earlier point, names of this data.table have been reassigned. Please ensure to use setnames() rather than names<- or colnames<-. Otherwise, please report to data.table issue tracker.")); // # nocov
529529
// Can growVector at this point easily enough, but it shouldn't happen in first place so leave it as
530530
// strong error message for now.
531-
else if (growable_max_size(names) != oldtncol)
531+
else if (growable_capacity(names) != oldtncol)
532532
// Use (long long) to cast R_xlen_t to a fixed type to robustly avoid -Wformat compiler warnings, see #5768, PRId64 didn't work
533-
internal_error(__func__, "selfrefnames is ok but tl names [%lld] != tl [%d]", (long long)growable_max_size(names), oldtncol); // # nocov
533+
internal_error(__func__, "selfrefnames is ok but tl names [%lld] != tl [%d]", (long long)growable_capacity(names), oldtncol); // # nocov
534534
if (!selfrefok(dt, verbose)) // #6410 setDT(dt) and subsequent attr<- can lead to invalid selfref
535535
error(_("It appears that at some earlier point, attributes of this data.table have been reassigned. Please use setattr(DT, name, value) rather than attr(DT, name) <- value. If that doesn't apply to you, please report your case to the data.table issue tracker."));
536536
growable_resize(dt, oldncol+LENGTH(newcolnames));

src/data.table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# define USE_GROWABLE_ALTREP
2121
#endif
2222
#include <Rinternals.h>
23+
#include <Rgrowable.h>
2324
#define SEXPPTR_RO(x) ((const SEXP *)DATAPTR_RO(x)) // to avoid overhead of looped STRING_ELT and VECTOR_ELT
2425
#include <stdint.h> // for uint64_t rather than unsigned long long
2526
#include <stdarg.h> // for va_list, va_start

src/dogroups.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
317317
RHS = VECTOR_ELT(jval,j%LENGTH(jval));
318318
if (isNull(target)) {
319319
// first time adding to new column
320-
if (growable_max_size(dt) < colj+1) internal_error(__func__, "Trying to add new column by reference but table is full; setalloccol should have run first at R level before getting to this point"); // # nocov
320+
if (growable_capacity(dt) < colj+1) internal_error(__func__, "Trying to add new column by reference but table is full; setalloccol should have run first at R level before getting to this point"); // # nocov
321321
target = PROTECT(allocNAVectorLike(RHS, n));
322322
// Even if we could know reliably to switch from allocNAVectorLike to allocVector for slight speedup, user code could still
323323
// contain a switched halt, and in that case we'd want the groups not yet done to have NA rather than 0 or uninitialized.

0 commit comments

Comments
 (0)