You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may likely require a dynamically growing hash of TRUELENGTHs
instead of the current pre-allocation approach with a very conservative
over-estimate.
// in future warn, or use list column instead ... warning(_("Column %d contains a factor but not all items for the column are character or factor"), idcol+j+1);
347
347
// some coercing from (likely) integer/numeric to character will be needed. But this coerce can feasibly fail with out-of-memory, so we have to do it up-front
348
-
// before the savetl_init() because we have no hook to clean up tl if coerceVector fails.
349
348
if (coercedForFactor==NULL) { coercedForFactor=PROTECT(allocVector(VECSXP, LENGTH(l))); nprotect++; }
// C spec states that if realloc() fails (above) the original block (levelsRaw) is left untouched: it is not freed or moved. We ...
449
-
for (intk=0; k<nLevel; k++) SET_TRUELENGTH(levelsRaw[k], 0); // ... rely on that in this loop which uses levelsRaw.
456
+
for (intk=0; k<nLevel; k++) hash_set(marks, levelsRaw[k], 0); // ... rely on that in this loop which uses levelsRaw.
450
457
free(levelsRaw);
451
-
savetl_end();
452
458
error(_("Failed to allocate working memory for %d factor levels of result column %d when reading item %d of item %d"), allocLevel, idcol+j+1, w+1, i+1);
for (intr=0; r<thisnrow; ++r) targetd[ansloc+r] =val;
504
510
} else {
505
-
for (intr=0; r<thisnrow; ++r) targetd[ansloc+r] =sd[r]==NA_STRING ? NA_INTEGER : -TRUELENGTH(sd[r]);
511
+
for (intr=0; r<thisnrow; ++r) targetd[ansloc+r] =sd[r]==NA_STRING ? NA_INTEGER : -hash_lookup(marks,sd[r],0);
506
512
}
507
513
}
508
514
}
509
515
ansloc+=thisnrow;
510
516
}
511
-
for (intk=0; k<nLevel; ++k) SET_TRUELENGTH(levelsRaw[k], 0);
512
-
savetl_end();
513
-
if (warnStr[0]) warning("%s", warnStr); // now savetl_end() has happened it's safe to call warning (could error if options(warn=2))
517
+
if (warnStr[0]) warning("%s", warnStr); // previously had to wait until savetl_end() for it to be safe to call warning (could error if options(warn=2))
0 commit comments