diff --git a/MD5 b/MD5 index 8fcb462..f9b0cba 100644 --- a/MD5 +++ b/MD5 @@ -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 @@ -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 @@ -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 diff --git a/src/dup.c b/src/dup.c index 634e5e9..4a9a363 100644 --- a/src/dup.c +++ b/src/dup.c @@ -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) { @@ -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; @@ -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; } @@ -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; } @@ -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 : { @@ -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; @@ -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; @@ -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)); @@ -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; } @@ -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)); @@ -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; } @@ -897,7 +897,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) { copyMostAttrib(x, ans); } } - Free(count); + R_Free(count); UNPROTECT(1); return ans; } @@ -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); @@ -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); @@ -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); @@ -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; @@ -1041,7 +1041,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) { ibld:; } } - Free(h); + R_Free(h); } } break; case REALSXP: { @@ -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); @@ -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; @@ -1127,7 +1127,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) { rbld:; } } - Free(h); + R_Free(h); } } break; case CPLXSXP: { @@ -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); @@ -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; @@ -1255,7 +1255,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) { cbld:; } } - Free(h); + R_Free(h); } } break; case STRSXP: { @@ -1291,7 +1291,7 @@ 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) { @@ -1299,7 +1299,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) { SET_STRING_ELT(indx, ct++, px[i]); } } - Free(pans); + R_Free(pans); copyMostAttrib(x, indx); UNPROTECT(1); return indx; @@ -1335,7 +1335,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) { sbld:; } } - Free(h); + R_Free(h); } } break; } @@ -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) { @@ -1475,7 +1475,7 @@ SEXP dupVecIndexOnlyR(SEXP x) { } } break; } - Free(h); + R_Free(h); UNPROTECT(1); return ans_i; } diff --git a/src/dupLen.c b/src/dupLen.c index 7ae7893..edbcc97 100644 --- a/src/dupLen.c +++ b/src/dupLen.c @@ -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) { @@ -98,7 +98,7 @@ SEXP dupLenDataFrameR(SEXP x) { count++; label2:; } - Free(h); + R_Free(h); UNPROTECT(1); return ScalarInteger(count); } @@ -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 : { @@ -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); } @@ -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; @@ -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; @@ -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); @@ -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); @@ -404,6 +404,6 @@ SEXP dupLenVecR(SEXP x) { } } break; } - Free(h); + R_Free(h); return ScalarInteger(count); } diff --git a/src/share.c b/src/share.c index d6c06c9..a0d9c59 100644 --- a/src/share.c +++ b/src/share.c @@ -64,7 +64,7 @@ static void map_finalizer (SEXP ext) { munmap(ptr->length, 256); shm_unlink(ptr->LENGTH_ID); #endif - Free(ptr); + R_Free(ptr); R_ClearExternalPtr(ext); if (verbose_finalizer) Rprintf("* Clear external pointer...OK\n"); } @@ -86,7 +86,7 @@ SEXP createMappingObjectR (SEXP MapObjectName, SEXP MapLengthName, SEXP DataObje const size_t BUF_SIZE = len*sizeof(Rbyte); if (verbose) Rprintf("* Data object size: %zu\n",len*sizeof(Rbyte)); if (verbose) Rprintf("* Start mapping object...OK\n"); - struct OBJECT *foo = Calloc(1, struct OBJECT); + struct OBJECT *foo = R_Calloc(1, struct OBJECT); SEXP ext = PROTECT(R_MakeExternalPtr(foo, R_NilValue, R_NilValue)); R_RegisterCFinalizerEx(ext, map_finalizer, TRUE); if (verbose) Rprintf("* Register finalizer...OK\n");