diff --git a/src/base.c b/src/base.c index 43788ef..dd80818 100644 --- a/src/base.c +++ b/src/base.c @@ -248,7 +248,7 @@ static SEXP rawToChar(const unsigned char *buf, const size_t sz) { if (sz - i > 1) { REprintf("data could not be converted to a character string\n"); out = Rf_allocVector(RAWSXP, sz); - memcpy(DATAPTR(out), buf, sz); + memcpy(SB_DATAPTR(out), buf, sz); return out; } @@ -377,7 +377,7 @@ SEXP secretbase_base64enc(SEXP x, SEXP convert) { out = rawToChar(buf, olen); } else { out = Rf_allocVector(RAWSXP, olen); - memcpy(DATAPTR(out), buf, olen); + memcpy(SB_DATAPTR(out), buf, olen); } R_Free(buf); @@ -416,7 +416,7 @@ SEXP secretbase_base64dec(SEXP x, SEXP convert) { switch (*(int *) DATAPTR_RO(convert)) { case 0: out = Rf_allocVector(RAWSXP, olen); - memcpy(DATAPTR(out), buf, olen); + memcpy(SB_DATAPTR(out), buf, olen); break; case 1: out = rawToChar(buf, olen); diff --git a/src/secret.c b/src/secret.c index 50c625d..60ff4a3 100644 --- a/src/secret.c +++ b/src/secret.c @@ -214,7 +214,7 @@ static void mbedtls_sha3_finish(mbedtls_sha3_context *ctx, uint8_t *output, size // secretbase - internals ------------------------------------------------------ -static inline int R_Integer(SEXP x) { +static inline int nano_integer(SEXP x) { int out; switch (TYPEOF(x)) { case INTSXP: @@ -315,7 +315,7 @@ SEXP hash_to_sexp(unsigned char *buf, size_t sz, int conv) { SEXP out; if (conv == 0) { out = Rf_allocVector(RAWSXP, sz); - memcpy(DATAPTR(out), buf, sz); + memcpy(SB_DATAPTR(out), buf, sz); } else if (conv == 1) { char cbuf[sz + sz + 1]; char *cptr = cbuf; @@ -326,7 +326,7 @@ SEXP hash_to_sexp(unsigned char *buf, size_t sz, int conv) { UNPROTECT(1); } else { out = Rf_allocVector(INTSXP, sz / sizeof(int)); - memcpy(DATAPTR(out), buf, sz); + memcpy(SB_DATAPTR(out), buf, sz); } return out; @@ -338,7 +338,7 @@ static SEXP secretbase_sha3_impl(const SEXP x, const SEXP bits, const SEXP conve const int offset) { const int conv = LOGICAL(convert)[0]; - const int bt = R_Integer(bits); + const int bt = nano_integer(bits); mbedtls_sha3_id id; if (offset < 0) { diff --git a/src/secret.h b/src/secret.h index 54c13d6..6920afb 100644 --- a/src/secret.h +++ b/src/secret.h @@ -26,6 +26,8 @@ #include #include +#define SB_DATAPTR(x) (void *) DATAPTR_RO(x) + #define SB_R_SERIAL_VER 3 #define SB_SERIAL_HEADERS 6 #define SB_BUF_SIZE 4096