Skip to content

Commit 22981ad

Browse files
committed
Remove savetl()
1 parent 962b272 commit 22981ad

File tree

2 files changed

+0
-57
lines changed

2 files changed

+0
-57
lines changed

src/assign.c

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,62 +1256,6 @@ SEXP allocNAVectorLike(SEXP x, R_len_t n) {
12561256
return(v);
12571257
}
12581258

1259-
static SEXP *saveds=NULL;
1260-
static R_len_t *savedtl=NULL, nalloc=0, nsaved=0;
1261-
1262-
void savetl_init(void) {
1263-
if (nsaved || nalloc || saveds || savedtl) {
1264-
internal_error(__func__, _("savetl_init checks failed (%d %d %p %p)"), nsaved, nalloc, (void *)saveds, (void *)savedtl); // # nocov
1265-
}
1266-
nsaved = 0;
1267-
nalloc = 100;
1268-
saveds = (SEXP *)malloc(nalloc * sizeof(SEXP));
1269-
savedtl = (R_len_t *)malloc(nalloc * sizeof(R_len_t));
1270-
if (!saveds || !savedtl) {
1271-
free(saveds); free(savedtl); // # nocov
1272-
savetl_end(); // # nocov
1273-
error(_("Failed to allocate initial %d items in savetl_init"), nalloc); // # nocov
1274-
}
1275-
}
1276-
1277-
void savetl(SEXP s)
1278-
{
1279-
if (nsaved==nalloc) {
1280-
if (nalloc==INT_MAX) {
1281-
savetl_end(); // # nocov
1282-
internal_error(__func__, "reached maximum %d items for savetl", nalloc); // # nocov
1283-
}
1284-
nalloc = nalloc>(INT_MAX/2) ? INT_MAX : nalloc*2;
1285-
char *tmp = (char *)realloc(saveds, nalloc*sizeof(SEXP));
1286-
if (tmp==NULL) {
1287-
// C spec states that if realloc() fails the original block is left untouched; it is not freed or moved. We rely on that here.
1288-
savetl_end(); // # nocov free(saveds) happens inside savetl_end
1289-
error(_("Failed to realloc saveds to %d items in savetl"), nalloc); // # nocov
1290-
}
1291-
saveds = (SEXP *)tmp;
1292-
tmp = (char *)realloc(savedtl, nalloc*sizeof(R_len_t));
1293-
if (tmp==NULL) {
1294-
savetl_end(); // # nocov
1295-
error(_("Failed to realloc savedtl to %d items in savetl"), nalloc); // # nocov
1296-
}
1297-
savedtl = (R_len_t *)tmp;
1298-
}
1299-
saveds[nsaved] = s;
1300-
savedtl[nsaved] = TRUELENGTH(s);
1301-
nsaved++;
1302-
}
1303-
1304-
void savetl_end(void) {
1305-
// Can get called if nothing has been saved yet (nsaved==0), or even if _init() hasn't been called yet (pointers NULL). Such
1306-
// as to clear up before error. Also, it might be that nothing needed to be saved anyway.
1307-
for (int i=0; i<nsaved; i++) SET_TRUELENGTH(saveds[i],savedtl[i]);
1308-
free(saveds); // possible free(NULL) which is safe no-op
1309-
saveds = NULL;
1310-
free(savedtl);
1311-
savedtl = NULL;
1312-
nsaved = nalloc = 0;
1313-
}
1314-
13151259
SEXP setcharvec(SEXP x, SEXP which, SEXP newx)
13161260
{
13171261
int w;

src/data.table.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ SEXP growVector(SEXP x, R_len_t newlen);
135135
SEXP allocNAVector(SEXPTYPE type, R_len_t n);
136136
SEXP allocNAVectorLike(SEXP x, R_len_t n);
137137
void writeNA(SEXP v, const int from, const int n, const bool listNA);
138-
void savetl_init(void), savetl(SEXP s), savetl_end(void);
139138
int checkOverAlloc(SEXP x);
140139

141140
// forder.c

0 commit comments

Comments
 (0)