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
nth=getDTthreads(nrow, true); // this nth is relied on in cleanup(); throttle=true/false debated for #5077
791
-
TMP=(int*)malloc(nth*UINT16_MAX*sizeof(int)); // used by counting sort (my_n<=65536) in radix_r()
792
-
UGRP=(uint8_t*)malloc(nth*256); // TODO: align TMP and UGRP to cache lines (and do the same for stack allocations too)
791
+
TMP=malloc(sizeof(*TMP)*nth*UINT16_MAX); // used by counting sort (my_n<=65536) in radix_r()
792
+
UGRP=malloc(sizeof(*UGRP)*nth*256); // TODO: align TMP and UGRP to cache lines (and do the same for stack allocations too)
793
793
if (!TMP|| !UGRP/*|| TMP%64 || UGRP%64*/) {
794
794
free(TMP); free(UGRP); // # nocov
795
795
STOP(_("Failed to allocate TMP or UGRP or they weren't cache line aligned: nth=%d"), nth); // # nocov
@@ -917,7 +917,7 @@ void radix_r(const int from, const int to, const int radix) {
917
917
#endif
918
918
919
919
uint8_t*restrict my_key=key[radix]+from; // safe to write as we don't use this radix again
920
-
uint8_t*o=(uint8_t*)malloc(my_n*sizeof(uint8_t));
920
+
uint8_t*o=malloc(sizeof(*o)*my_n);
921
921
if (!o)
922
922
STOP(_("Failed to allocate %d bytes for '%s'."), (int)(my_n*sizeof(uint8_t)), "o"); // # nocov
923
923
// if last key (i.e. radix+1==nradix) there are no more keys to reorder so we could reorder osub by reference directly and save allocating and populating o just
@@ -986,10 +986,10 @@ void radix_r(const int from, const int to, const int radix) {
986
986
}
987
987
if (!skip) {
988
988
// reorder osub and each remaining ksub
989
-
int*TMP=malloc(my_n*sizeof(int));
989
+
int*TMP=malloc(sizeof(*TMP) *my_n);
990
990
if (!TMP) {
991
991
free(o); // # nocov
992
-
STOP(_("Failed to allocate %d bytes for '%s'."), (int)(my_n*sizeof(int)), "TMP"); // # nocov
992
+
STOP(_("Failed to allocate %d bytes for '%s'."), (int)(sizeof(*TMP) *my_n), "TMP"); // # nocov
993
993
}
994
994
constint*restrict osub=anso+from;
995
995
for (inti=0; i<my_n; i++) TMP[i] =osub[o[i]];
@@ -1009,9 +1009,9 @@ void radix_r(const int from, const int to, const int radix) {
1009
1009
return;
1010
1010
}
1011
1011
intngrp=0; //minor TODO: could know number of groups with certainty up above
1012
-
int*my_gs=malloc(my_n*sizeof(int));
1012
+
int*my_gs=malloc(sizeof(*my_gs) *my_n);
1013
1013
if (!my_gs)
1014
-
STOP(_("Failed to allocate %d bytes for '%s'."), (int)(my_n*sizeof(int)), "my_gs"); // # nocov
1014
+
STOP(_("Failed to allocate %d bytes for '%s'."), (int)(sizeof(*my_gs) *my_n), "my_gs"); // # nocov
1015
1015
my_gs[ngrp]=1;
1016
1016
for (inti=1; i<my_n; i++) {
1017
1017
if (my_key[i]!=my_key[i-1]) my_gs[++ngrp] =1;
@@ -1111,7 +1111,7 @@ void radix_r(const int from, const int to, const int radix) {
1111
1111
if (!retgrp&&radix+1==nradix) {
1112
1112
return; // we're done. avoid allocating and populating very last group sizes for last key
1113
1113
}
1114
-
int*my_gs=malloc((ngrp==0 ? 256 : ngrp) *sizeof(int)); // ngrp==0 when sort and skip==true; we didn't count the non-zeros in my_counts yet in that case
1114
+
int*my_gs=malloc(sizeof(*my_gs) * (ngrp==0 ? 256 : ngrp)); // ngrp==0 when sort and skip==true; we didn't count the non-zeros in my_counts yet in that case
1115
1115
if (!my_gs)
1116
1116
STOP(_("Failed to allocate %d bytes for '%s'."), (int)((ngrp==0 ? 256 : ngrp) *sizeof(int)), "my_gs"); // # nocov
1117
1117
if (sortType!=0) {
@@ -1139,9 +1139,9 @@ void radix_r(const int from, const int to, const int radix) {
tmpType=(int8_t*)malloc((size_t)ncol*sizeof(int8_t)); // used i) in sampling to not stop on errors when bad jump point and ii) when accepting user overrides
1887
+
type=malloc(sizeof(*type)*(size_t)ncol);
1888
+
tmpType=malloc(sizeof(*tmpType)*(size_t)ncol); // used i) in sampling to not stop on errors when bad jump point and ii) when accepting user overrides
1889
1889
if (!type|| !tmpType) {
1890
1890
free(type); free(tmpType); // # nocov
1891
1891
STOP(_("Failed to allocate 2 x %d bytes for type and tmpType: %s"), ncol, strerror(errno)); // # nocov
@@ -2201,9 +2201,9 @@ int freadMain(freadMainArgs _args) {
2201
2201
rowSize1=0;
2202
2202
rowSize4=0;
2203
2203
rowSize8=0;
2204
-
size=(int8_t*)malloc((size_t)ncol*sizeof(int8_t)); // TODO: remove size[] when we implement Pasha's idea to += size inside processor
2204
+
size=malloc(sizeof(*size)*(size_t)ncol); // TODO: remove size[] when we implement Pasha's idea to += size inside processor
2205
2205
if (!size)
2206
-
STOP(_("Failed to allocate %d bytes for '%s': %s"), (int)(ncol*sizeof(int8_t)), "size", strerror(errno)); // # nocov
2206
+
STOP(_("Failed to allocate %d bytes for '%s': %s"), (int)(sizeof(*size)*(size_t)ncol), "size", strerror(errno)); // # nocov
2207
2207
nStringCols=0;
2208
2208
nNonStringCols=0;
2209
2209
for (intj=0; j<ncol; j++) {
@@ -2642,7 +2642,7 @@ int freadMain(freadMainArgs _args) {
2642
2642
DTPRINT(_(" Provided number of fill columns: %d but only found %d\n"), ncol, max_col);
0 commit comments