@@ -400,7 +400,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
400400 // FR #2077 - set able to add new cols by reference
401401 if (isString (cols )) {
402402 PROTECT (tmp = chmatch (cols , names , 0 )); protecti ++ ;
403- buf = (int * ) R_alloc (length (cols ), sizeof (int ));
403+ buf = (int * ) R_alloc (length (cols ), sizeof (* buf ));
404404 int k = 0 ;
405405 for (int i = 0 ; i < length (cols ); ++ i ) {
406406 if (INTEGER (tmp )[i ] == 0 ) buf [k ++ ] = i ;
@@ -699,7 +699,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
699699 }
700700 if (ndelete ) {
701701 // delete any columns assigned NULL (there was a 'continue' earlier in loop above)
702- int * tt = (int * )R_alloc (ndelete , sizeof (int ));
702+ int * tt = (int * )R_alloc (ndelete , sizeof (* tt ));
703703 const int * colsd = INTEGER (cols ), ncols = length (cols ), ndt = length (dt );
704704 for (int i = 0 , k = 0 ; i < ncols ; ++ i ) { // find which ones to delete and put them in tt
705705 // Aside: a new column being assigned NULL (something odd to do) would have been warned above, added above, and now deleted. Just
@@ -1055,7 +1055,7 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
10551055 case RAWSXP : BODY (Rbyte , RAW , int , val != 0 , td [i ]= cval )
10561056 case LGLSXP :
10571057 if (mc ) {
1058- memcpy (td , LOGICAL_RO (source ), slen * sizeof (int )); break ;
1058+ memcpy (td , LOGICAL_RO (source ), slen * sizeof (* td )); break ;
10591059 } else BODY (int , LOGICAL , int , val , td [i ]= cval )
10601060 case INTSXP : BODY (int , INTEGER , int , val == NA_INTEGER ? NA_LOGICAL : val != 0 , td [i ]= cval )
10611061 case REALSXP :
@@ -1072,7 +1072,7 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
10721072 case LGLSXP : // same as INTSXP ...
10731073 case INTSXP :
10741074 if (mc ) {
1075- memcpy (td , INTEGER_RO (source ), slen * sizeof (int )); break ;
1075+ memcpy (td , INTEGER_RO (source ), slen * sizeof (* td )); break ;
10761076 } else BODY (int , INTEGER , int , val , td [i ]= cval )
10771077 case REALSXP :
10781078 if (sourceIsI64 )
@@ -1092,7 +1092,7 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
10921092 case REALSXP :
10931093 if (sourceIsI64 ) {
10941094 if (mc ) {
1095- memcpy (td , (const int64_t * )REAL_RO (source ), slen * sizeof (int64_t )); break ;
1095+ memcpy (td , (const int64_t * )REAL_RO (source ), slen * sizeof (* td )); break ;
10961096 } else BODY (int64_t , REAL , int64_t , val , td [i ]= cval )
10971097 } else BODY (double , REAL , int64_t , within_int64_repres (val ) ? val : NA_INTEGER64 , td [i ]= cval )
10981098 case CPLXSXP : BODY (Rcomplex , COMPLEX , int64_t , ISNAN (val .r ) ? NA_INTEGER64 : (int64_t )val .r , td [i ]= cval )
@@ -1291,14 +1291,14 @@ void savetl(SEXP s)
12911291 internal_error (__func__ , "reached maximum %d items for savetl" , nalloc ); // # nocov
12921292 }
12931293 nalloc = nalloc > (INT_MAX /2 ) ? INT_MAX : nalloc * 2 ;
1294- char * tmp = ( char * ) realloc (saveds , nalloc * sizeof (SEXP ));
1294+ char * tmp = realloc (saveds , sizeof (SEXP )* nalloc );
12951295 if (tmp == NULL ) {
12961296 // C spec states that if realloc() fails the original block is left untouched; it is not freed or moved. We rely on that here.
12971297 savetl_end (); // # nocov free(saveds) happens inside savetl_end
12981298 error (_ ("Failed to realloc saveds to %d items in savetl" ), nalloc ); // # nocov
12991299 }
13001300 saveds = (SEXP * )tmp ;
1301- tmp = ( char * ) realloc (savedtl , nalloc * sizeof (R_len_t ));
1301+ tmp = realloc (savedtl , sizeof (R_len_t )* nalloc );
13021302 if (tmp == NULL ) {
13031303 savetl_end (); // # nocov
13041304 error (_ ("Failed to realloc savedtl to %d items in savetl" ), nalloc ); // # nocov
0 commit comments