From d105399baca2b289848097493014bc87189b6627 Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:59:50 +0100 Subject: [PATCH] compact code --- DESCRIPTION | 2 +- NEWS.md | 2 +- src/aio.c | 20 ++++++++------------ tests/tests.R | 1 + 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ec71e3889..e9d16a017 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: nanonext Type: Package Title: NNG (Nanomsg Next Gen) Lightweight Messaging Library -Version: 0.10.2.9011 +Version: 0.10.2.9012 Description: R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is a socket library providing high-performance scalability protocols, a cross-platform standard for messaging and communications. Serves as a diff --git a/NEWS.md b/NEWS.md index 828236209..468907d3a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# nanonext 0.10.2.9011 (development) +# nanonext 0.10.2.9012 (development) #### New Features diff --git a/src/aio.c b/src/aio.c index 4ac3a3b3a..609f0e61e 100644 --- a/src/aio.c +++ b/src/aio.c @@ -861,16 +861,13 @@ SEXP rnng_send_aio(SEXP con, SEXP data, SEXP mode, SEXP timeout, SEXP clo) { nano_serialize_next(&buf, data); break; } - if ((xc = nng_msg_alloc(&msg, 0))) { - NANO_FREE(buf); - goto exitlevel1; - } + if ((xc = nng_msg_alloc(&msg, 0))) + goto exitlevel2; if ((xc = nng_msg_append(msg, buf.buf, buf.cur)) || (xc = nng_aio_alloc(&saio->aio, saio_complete, saio))) { nng_msg_free(msg); - NANO_FREE(buf); - goto exitlevel1; + goto exitlevel2; } nng_aio_set_msg(saio->aio, msg); @@ -897,16 +894,13 @@ SEXP rnng_send_aio(SEXP con, SEXP data, SEXP mode, SEXP timeout, SEXP clo) { nano_serialize_next(&buf, data); break; } - if ((xc = nng_msg_alloc(&msg, 0))) { - NANO_FREE(buf); - goto exitlevel1; - } + if ((xc = nng_msg_alloc(&msg, 0))) + goto exitlevel2; if ((xc = nng_msg_append(msg, buf.buf, buf.cur)) || (xc = nng_aio_alloc(&saio->aio, saio_complete, saio))) { nng_msg_free(msg); - NANO_FREE(buf); - goto exitlevel1; + goto exitlevel2; } nng_aio_set_msg(saio->aio, msg); @@ -968,6 +962,8 @@ SEXP rnng_send_aio(SEXP con, SEXP data, SEXP mode, SEXP timeout, SEXP clo) { UNPROTECT(3); return env; + exitlevel2: + NANO_FREE(buf); exitlevel1: R_Free(saio); return mk_error_data(-xc); diff --git a/tests/tests.R b/tests/tests.R index 55b5be1ad..e7de436fd 100644 --- a/tests/tests.R +++ b/tests/tests.R @@ -363,6 +363,7 @@ nanotest(is_error_value(sess) || length(transact(sess)) == 3L) nanotest(is_error_value(sess) || close(sess) == 0L) nanotesterr(transact(sess), "ncurlSession") nanotestw(is_error_value(ncurl_session("https://i"))) +nanotesterr(ncurl("https://www.cam.ac.uk/", tls = "wrong"), "valid TLS") nanotesterr(stream(dial = "wss://127.0.0.1:5555")) nanotesterr(stream(dial = "wss://127.0.0.1:5555", tls = "wrong"), "valid TLS") nanotesterr(stream(listen = "errorValue3"), "argument")