Skip to content

Commit

Permalink
Attempt at fixing some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
2005m committed Sep 7, 2024
1 parent 8edc12c commit 57f2e77
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 53 deletions.
12 changes: 6 additions & 6 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
6071edd604dbeb75308cfbedc7790398 *cleanup
d2761d00effd7b096a5bea21bc38742e *configure
333734960a1399c3fb463327554da3e2 *DESCRIPTION
66302e8b5f49ea7f34b2608a1f397f52 *inst/NEWS.Rd
8522c4bb9195d54629546f67108343b2 *DESCRIPTION
28ac3ba56b8c042c2ffcc247881367a2 *inst/NEWS.Rd
a87b0f223435ed35607e8514562b8bfe *LICENSE
2ddfa8d8739668eedda260e6ddc935d4 *man/charToFact.Rd
8f19a2c9feb2f352580fd4892650f285 *man/count.Rd
Expand All @@ -17,9 +17,9 @@ a137f7855b41b074e2babaf8a1562551 *man/shareData.Rd
a7f31cee15b9624dab8f4d13d3c66bad *man/vswitch.Rd
c797ca387dccc02751cfe85108fb0159 *NAMESPACE
4eb6d6a80ed6d9396f89c21ff11ff3e0 *R/call.R
2d6c06dfc570d456af125c160cf150d7 *README.md
7772ede8a29575aee4fc449383fa5008 *src/dup.c
2b2b6f22af562d8c40127c69cc541331 *src/dupLen.c
a05428b6647b841b77139b15e180a82c *README.md
a5a903a410a187a46f7507c9df49f63a *src/dup.c
3781c4e2abdce2dbca33f53ac8713e8c *src/dupLen.c
5eaee76c99ff42679577592ae9c5a29f *src/fpos.c
015be143fce94516ad10b968df592df5 *src/iif.c
6d91dc90d2db4ede5f044b824d4f34a3 *src/init.c
Expand All @@ -29,7 +29,7 @@ a52426250b954a335b1121948e057ee7 *src/Makevars.in
1e8b11cf04b116653c0a82a20f72490b *src/nswitch.c
0bb2655499d4ac66b45be687d6fae6e9 *src/psort.c
8c15e9c171d447aed088cec849323fab *src/psum.c
7589054d8388fe7ed3354a5aa388eb02 *src/share.c
d3de1fdedb3870cebd670f7bfde188cc *src/share.c
ef9329d7e748c13b9526fca1788a1891 *src/topn.c
58a06280212a06ea2b8039bebb03fcdf *src/utils.c
37787d47d80dfd40bc3d12699ed30441 *src/vswitch.c
Expand Down
68 changes: 34 additions & 34 deletions src/dup.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ SEXP dupDataFrameR(SEXP x, SEXP uniq, SEXP fromLast) { // move to matrix if poss
K++;
}
R_xlen_t count = 0;
int *restrict h = (int*) Calloc(M, int);
int *restrict h = (int*) R_Calloc(M, int);
const int *restrict v = INTEGER(mlv);
int *restrict pans = buniq ? (int*) Calloc(len_i, int) : LOGICAL(ans);
int *restrict pans = buniq ? (int*) R_Calloc(len_i, int) : LOGICAL(ans);
size_t id = 0;
if (buniq) {
if (pfromLast) {
Expand Down Expand Up @@ -131,7 +131,7 @@ SEXP dupDataFrameR(SEXP x, SEXP uniq, SEXP fromLast) { // move to matrix if poss
label2:;
}
}
Free(h);
R_Free(h);
UNPROTECT(1);
SEXP indx = PROTECT(allocVector(INTSXP, count));
int ct = 0;
Expand All @@ -142,7 +142,7 @@ SEXP dupDataFrameR(SEXP x, SEXP uniq, SEXP fromLast) { // move to matrix if poss
}
}
SEXP output = PROTECT(subSetRowDataFrame(x, indx));
Free(pans);
R_Free(pans);
UNPROTECT(2);
return output;
}
Expand Down Expand Up @@ -193,7 +193,7 @@ SEXP dupDataFrameR(SEXP x, SEXP uniq, SEXP fromLast) { // move to matrix if poss
label2b:;
}
}
Free(h);
R_Free(h);
UNPROTECT(2);
return ans;
}
Expand All @@ -219,8 +219,8 @@ SEXP dupMatrixR(SEXP x, SEXP uniq, Rboolean idx, SEXP fromLast) {
K++;
}
R_xlen_t count = 0;
int *restrict h = (int*) Calloc(M, int);
int *restrict pans = buniq ? (int*) Calloc(len_i, int) : LOGICAL(ans);
int *restrict h = (int*) R_Calloc(M, int);
int *restrict pans = buniq ? (int*) R_Calloc(len_i, int) : LOGICAL(ans);
size_t id = 0;
switch(UTYPEOF(x)) {
case LGLSXP : {
Expand Down Expand Up @@ -770,13 +770,13 @@ SEXP dupMatrixR(SEXP x, SEXP uniq, Rboolean idx, SEXP fromLast) {
}
} break;
default: {
Free(h);
R_Free(h);
if (buniq)
Free(pans);
R_Free(pans);
error("Matrix of type %s are not supported.", type2char(UTYPEOF(x)));
}
}
Free(h);
R_Free(h);
if (buniq) {
SEXP indx = PROTECT(allocVector(INTSXP, count));
int ct = 0;
Expand All @@ -786,7 +786,7 @@ SEXP dupMatrixR(SEXP x, SEXP uniq, Rboolean idx, SEXP fromLast) {
py[ct++] = i;
}
}
Free(pans);
R_Free(pans);
if (idx) {
UNPROTECT(1);
return indx;
Expand All @@ -812,7 +812,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
if (isFactor(x) && buniq) {
const int len = LENGTH(PROTECT(getAttrib(x, R_LevelsSymbol)));
UNPROTECT(1);
bool *restrict count = (bool*)Calloc(len+1,bool);
bool *restrict count = (bool*)R_Calloc(len+1,bool);
const int *restrict px = INTEGER(x);
const int xlen = LENGTH(x);
SEXP ans = PROTECT(allocVector(INTSXP, len));
Expand All @@ -832,7 +832,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
SEXP ans2 = PROTECT(allocVector(INTSXP, len-j-1));
copyMostAttrib(x, ans2);
memcpy(INTEGER(ans2),pans+j+1,(len-j-1)*sizeof(int));
Free(count);
R_Free(count);
UNPROTECT(2);
return ans2;
}
Expand All @@ -851,12 +851,12 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
copyMostAttrib(x, ans);
}
}
Free(count);
R_Free(count);
UNPROTECT(1);
return ans;
}
if (isLogical(x) && buniq) {
bool *restrict count = (bool*)Calloc(3,bool);
bool *restrict count = (bool*)R_Calloc(3,bool);
const int *restrict px = LOGICAL(x);
const int xlen = LENGTH(x);
SEXP ans = PROTECT(allocVector(LGLSXP, 3));
Expand All @@ -877,7 +877,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
SEXP ans2 = PROTECT(allocVector(LGLSXP, 2-j));
copyMostAttrib(x, ans2);
memcpy(LOGICAL(ans2),pans+j+1,(2-j)*sizeof(int));
Free(count);
R_Free(count);
UNPROTECT(2);
return ans2;
}
Expand All @@ -897,7 +897,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
copyMostAttrib(x, ans);
}
}
Free(count);
R_Free(count);
UNPROTECT(1);
return ans;
}
Expand All @@ -923,9 +923,9 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
error("Type %s is not supported.", type2char(tx));
}
size_t count = 0;
int *restrict h = (int*)Calloc(M, int);
int *restrict h = (int*)R_Calloc(M, int);
SEXP ans = buniq ? R_NilValue : PROTECT(allocVector(LGLSXP, n));
int *restrict pans = buniq ? (int*)Calloc(n, int) : LOGICAL(ans);
int *restrict pans = buniq ? (int*)R_Calloc(n, int) : LOGICAL(ans);
switch (tx) {
case LGLSXP: {
const int *restrict px = LOGICAL(x);
Expand Down Expand Up @@ -961,7 +961,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
lbld:;
}
}
Free(h);
R_Free(h);
} break;
case INTSXP: { // think about factor and levels number
const int *restrict px = INTEGER(x);
Expand Down Expand Up @@ -996,7 +996,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
ibl:;
}
}
Free(h);
R_Free(h);
SEXP indx = PROTECT(allocVector(tx, count));
size_t ct = 0;
int *restrict py = INTEGER(indx);
Expand All @@ -1005,7 +1005,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
py[ct++] = px[i];
}
}
Free(pans);
R_Free(pans);
copyMostAttrib(x, indx);
UNPROTECT(1);
return indx;
Expand Down Expand Up @@ -1041,7 +1041,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
ibld:;
}
}
Free(h);
R_Free(h);
}
} break;
case REALSXP: {
Expand Down Expand Up @@ -1080,7 +1080,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
rbl:;
}
}
Free(h);
R_Free(h);
SEXP indx = PROTECT(allocVector(tx, count));
size_t ct = 0;
double *restrict py = REAL(indx);
Expand All @@ -1089,7 +1089,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
py[ct++] = px[i];
}
}
Free(pans);
R_Free(pans);
copyMostAttrib(x, indx);
UNPROTECT(1);
return indx;
Expand Down Expand Up @@ -1127,7 +1127,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
rbld:;
}
}
Free(h);
R_Free(h);
}
} break;
case CPLXSXP: {
Expand Down Expand Up @@ -1188,7 +1188,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
cbl:;
}
}
Free(h);
R_Free(h);
SEXP indx = PROTECT(allocVector(tx, count));
size_t ct = 0;
Rcomplex *restrict py = COMPLEX(indx);
Expand All @@ -1197,7 +1197,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
py[ct++] = px[i];
}
}
Free(pans);
R_Free(pans);
copyMostAttrib(x, indx);
UNPROTECT(1);
return indx;
Expand Down Expand Up @@ -1255,7 +1255,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
cbld:;
}
}
Free(h);
R_Free(h);
}
} break;
case STRSXP: {
Expand Down Expand Up @@ -1291,15 +1291,15 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
sbl:;
}
}
Free(h);
R_Free(h);
SEXP indx = PROTECT(allocVector(tx, count));
size_t ct = 0;
for (int i = 0; ct < count; ++i) {
if (pans[i]) {
SET_STRING_ELT(indx, ct++, px[i]);
}
}
Free(pans);
R_Free(pans);
copyMostAttrib(x, indx);
UNPROTECT(1);
return indx;
Expand Down Expand Up @@ -1335,7 +1335,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
sbld:;
}
}
Free(h);
R_Free(h);
}
} break;
}
Expand Down Expand Up @@ -1369,7 +1369,7 @@ SEXP dupVecIndexOnlyR(SEXP x) {
} else {
error("Type %s is not supported.", type2char(tx)); // # nocov
}
int *restrict h = (int*)Calloc(M, int);
int *restrict h = (int*)R_Calloc(M, int);
SEXP ans_i = PROTECT(allocVector(INTSXP, n));
int *restrict pans_i = INTEGER(ans_i);
switch (tx) {
Expand Down Expand Up @@ -1475,7 +1475,7 @@ SEXP dupVecIndexOnlyR(SEXP x) {
}
} break;
}
Free(h);
R_Free(h);
UNPROTECT(1);
return ans_i;
}
22 changes: 11 additions & 11 deletions src/dupLen.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ SEXP dupLenDataFrameR(SEXP x) {
K++;
}
R_xlen_t count = 0;
int *restrict h = (int*) Calloc(M, int);
int *restrict h = (int*) R_Calloc(M, int);
const int *restrict v = INTEGER(mlv);
size_t id = 0;
for (R_xlen_t i = 0; i < len_i; ++i) {
Expand All @@ -98,7 +98,7 @@ SEXP dupLenDataFrameR(SEXP x) {
count++;
label2:;
}
Free(h);
R_Free(h);
UNPROTECT(1);
return ScalarInteger(count);
}
Expand All @@ -118,7 +118,7 @@ SEXP dupLenMatrixR(SEXP x) {
K++;
}
R_xlen_t count = 0;
int *restrict h = (int*) Calloc(M, int);
int *restrict h = (int*) R_Calloc(M, int);
size_t id = 0;
switch(UTYPEOF(x)) {
case LGLSXP : {
Expand Down Expand Up @@ -254,11 +254,11 @@ SEXP dupLenMatrixR(SEXP x) {
}
} break;
default: {
Free(h);
R_Free(h);
error("Matrix of type %s are not supported.", type2char(UTYPEOF(x)));
}
}
Free(h);
R_Free(h);
return ScalarInteger(count);
}

Expand All @@ -270,7 +270,7 @@ SEXP dupLenVecR(SEXP x) {
if (isFactor(x)) {
const int len = LENGTH(PROTECT(getAttrib(x, R_LevelsSymbol)));
UNPROTECT(1);
bool *restrict count = (bool*)Calloc(len+1,bool);
bool *restrict count = (bool*)R_Calloc(len+1,bool);
const int *restrict px = INTEGER(x);
const int xlen = LENGTH(x);
int j = 0;
Expand All @@ -282,11 +282,11 @@ SEXP dupLenVecR(SEXP x) {
count[px[i]] = true;
}
}
Free(count);
R_Free(count);
return ScalarInteger(j);
}
if (isLogical(x)) {
bool *restrict count = (bool*)Calloc(3,bool);
bool *restrict count = (bool*)R_Calloc(3,bool);
const int *restrict px = LOGICAL(x);
const int xlen = LENGTH(x);
int j = 0;
Expand All @@ -299,7 +299,7 @@ SEXP dupLenVecR(SEXP x) {
count[cs] = true;
}
}
Free(count);
R_Free(count);
return ScalarInteger(j);
}
const R_xlen_t n = xlength(x);
Expand All @@ -321,7 +321,7 @@ SEXP dupLenVecR(SEXP x) {
error("Type %s is not supported.", type2char(tx)); // # nocov
}
R_xlen_t count = 0;
int *restrict h = (int*)Calloc(M, int);
int *restrict h = (int*)R_Calloc(M, int);
switch (tx) {
case INTSXP: {
const int *restrict px = INTEGER(x);
Expand Down Expand Up @@ -404,6 +404,6 @@ SEXP dupLenVecR(SEXP x) {
}
} break;
}
Free(h);
R_Free(h);
return ScalarInteger(count);
}
Loading

0 comments on commit 57f2e77

Please sign in to comment.