Skip to content

Commit ed7726b

Browse files
committed
unsigned char *bufs
1 parent f1abeb3 commit ed7726b

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

nanonext.Rproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ StripTrailingWhitespace: Yes
1717

1818
BuildType: Package
1919
PackageUseDevtools: Yes
20+
PackageCleanBeforeInstall: Yes
2021
PackageInstallArgs: --no-multiarch --with-keep.source

src/aio.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ SEXP rnng_aio_get_msg(SEXP aio, SEXP mode, SEXP keep) {
181181
return mk_error(res);
182182

183183
const int mod = INTEGER(mode)[0], kpr = LOGICAL(keep)[0];
184-
void *buf = nng_msg_body(raio->data);
184+
unsigned char *buf = nng_msg_body(raio->data);
185185
size_t sz = nng_msg_len(raio->data);
186186

187187
return nano_decode(buf, sz, mod, kpr);
@@ -210,9 +210,10 @@ SEXP rnng_aio_stream_in(SEXP aio, SEXP mode, SEXP keep) {
210210

211211
const int mod = INTEGER(mode)[0], kpr = LOGICAL(keep)[0];
212212
nng_iov *iov = (nng_iov *) iaio->data;
213+
unsigned char *buf = iov->iov_buf;
213214
size_t sz = nng_aio_count(iaio->aio);
214215

215-
return nano_decode(iov->iov_buf, sz, mod, kpr);
216+
return nano_decode(buf, sz, mod, kpr);
216217

217218
}
218219

src/core.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ SEXP rnng_serial(SEXP mode) {
4444
SEXP nano_encode(SEXP object) {
4545

4646
R_xlen_t xlen = Rf_xlength(object);
47-
void *buf;
4847
size_t sz;
4948
SEXP out;
5049

5150
if (!Rf_isVectorAtomic(object))
5251
error_return("'data' is not an atomic vector type");
5352
if (TYPEOF(object) == STRSXP) {
5453
const char *s;
54+
unsigned char *buf;
5555
size_t np, outlen = 0;
5656
R_xlen_t i;
5757
for (i = 0; i < xlen; i++)
@@ -67,28 +67,24 @@ SEXP nano_encode(SEXP object) {
6767
} else {
6868
switch (TYPEOF(object)) {
6969
case REALSXP:
70-
buf = REAL(object);
7170
sz = xlen * sizeof(double);
7271
out = Rf_allocVector(RAWSXP, sz);
73-
memcpy(RAW(out), buf, sz);
72+
memcpy(RAW(out), REAL(object), sz);
7473
break;
7574
case INTSXP:
76-
buf = INTEGER(object);
7775
sz = xlen * sizeof(int);
7876
out = Rf_allocVector(RAWSXP, sz);
79-
memcpy(RAW(out), buf, sz);
77+
memcpy(RAW(out), INTEGER(object), sz);
8078
break;
8179
case LGLSXP:
82-
buf = LOGICAL(object);
8380
sz = xlen * sizeof(int);
8481
out = Rf_allocVector(RAWSXP, sz);
85-
memcpy(RAW(out), buf, sz);
82+
memcpy(RAW(out), LOGICAL(object), sz);
8683
break;
8784
case CPLXSXP:
88-
buf = COMPLEX(object);
8985
sz = xlen * (sizeof(double) + sizeof(double));
9086
out = Rf_allocVector(RAWSXP, sz);
91-
memcpy(RAW(out), buf, sz);
87+
memcpy(RAW(out), COMPLEX(object), sz);
9288
break;
9389
case RAWSXP:
9490
out = object;
@@ -199,7 +195,7 @@ SEXP rnng_matchargs(SEXP mode) {
199195

200196
}
201197

202-
SEXP nano_decode(void *buf, size_t sz, const int mod, const int kpr) {
198+
SEXP nano_decode(unsigned char *buf, size_t sz, const int mod, const int kpr) {
203199

204200
int tryErr = 0;
205201
SEXP raw, data;
@@ -751,7 +747,7 @@ SEXP rnng_recv(SEXP socket, SEXP mode, SEXP block, SEXP keep) {
751747
mode = rnng_matcharg(mode);
752748
const int mod = INTEGER(mode)[0], kpr = LOGICAL(keep)[0];
753749
int xc;
754-
void *buf;
750+
unsigned char *buf;
755751
size_t sz;
756752
nng_aio *aiop;
757753
SEXP res;
@@ -847,7 +843,7 @@ SEXP rnng_ctx_recv(SEXP context, SEXP mode, SEXP timeout, SEXP keep) {
847843
mode = rnng_matcharg(mode);
848844
const int mod = INTEGER(mode)[0], kpr = LOGICAL(keep)[0];
849845
int xc;
850-
void *buf;
846+
unsigned char *buf;
851847
size_t sz;
852848
SEXP res;
853849

@@ -946,6 +942,7 @@ SEXP rnng_stream_recv(SEXP stream, SEXP mode, SEXP timeout, SEXP keep, SEXP byte
946942
const size_t xlen = (size_t) Rf_asInteger(bytes);
947943
nng_duration dur;
948944
int xc;
945+
unsigned char *buf;
949946
size_t sz;
950947
nng_iov iov;
951948
nng_aio *aiop;
@@ -985,8 +982,9 @@ SEXP rnng_stream_recv(SEXP stream, SEXP mode, SEXP timeout, SEXP keep, SEXP byte
985982
return mk_error(xc);
986983
}
987984

985+
buf = iov.iov_buf;
988986
sz = nng_aio_count(aiop);
989-
res = nano_decode(iov.iov_buf, sz, mod, kpr);
987+
res = nano_decode(buf, sz, mod, kpr);
990988
nng_aio_free(aiop);
991989
R_Free(iov.iov_buf);
992990

src/nanonext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#ifdef NANONEXT_INTERNALS
3636
extern SEXP mk_error(const int);
37-
extern SEXP nano_decode(void *, size_t, const int, const int);
37+
extern SEXP nano_decode(unsigned char *, size_t, const int, const int);
3838
extern SEXP nano_encode(SEXP);
3939
extern SEXP rawOneString(unsigned char *, R_xlen_t, R_xlen_t *);
4040
extern void socket_finalizer(SEXP);

src/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ static void thread_finalizer(SEXP xptr) {
474474
static void rnng_thread(void *arg) {
475475

476476
nng_socket *sock = (nng_socket *) arg;
477-
void *buf;
477+
unsigned char *buf;
478478
size_t sz;
479479
time_t now;
480480
struct tm *tms;

0 commit comments

Comments
 (0)