Skip to content

Commit 632f000

Browse files
committed
one more simplification
1 parent 2774097 commit 632f000

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/utils.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@
2323

2424
// internals -------------------------------------------------------------------
2525

26-
typedef enum nano_stream_typ {
27-
DIALER,
28-
LISTENER
29-
} nano_stream_typ;
30-
3126
typedef struct nano_stream_s {
3227
nng_stream *stream;
33-
nano_stream_typ type;
28+
enum {
29+
STREAM_DIALER,
30+
STREAM_LISTENER
31+
} type;
3432
union {
3533
nng_stream_dialer *dial;
3634
nng_stream_listener *list;
@@ -61,7 +59,7 @@ static void stream_finalizer(SEXP xptr) {
6159
nano_stream *xp = (nano_stream *) R_ExternalPtrAddr(xptr);
6260
nng_stream_close(xp->stream);
6361
nng_stream_free(xp->stream);
64-
if (xp->type == DIALER) {
62+
if (xp->type == STREAM_DIALER) {
6563
nng_stream_dialer_close(xp->endpoint.dial);
6664
nng_stream_dialer_free(xp->endpoint.dial);
6765
} else {
@@ -369,7 +367,7 @@ SEXP rnng_stream_dial(SEXP url, SEXP textframes, SEXP tls) {
369367
if (tls != R_NilValue && R_ExternalPtrTag(tls) != nano_TlsSymbol)
370368
Rf_error("'tls' is not a valid TLS Configuration");
371369
nano_stream *nst = R_Calloc(1, nano_stream);
372-
nst->type = DIALER;
370+
nst->type = STREAM_DIALER;
373371
nst->tls = NULL;
374372
nng_url *up;
375373
nng_aio *aiop;
@@ -462,7 +460,7 @@ SEXP rnng_stream_listen(SEXP url, SEXP textframes, SEXP tls) {
462460
if (tls != R_NilValue && R_ExternalPtrTag(tls) != nano_TlsSymbol)
463461
Rf_error("'tls' is not a valid TLS Configuration");
464462
nano_stream *nst = R_Calloc(1, nano_stream);
465-
nst->type = LISTENER;
463+
nst->type = STREAM_LISTENER;
466464
nst->tls = NULL;
467465
nng_url *up;
468466
nng_aio *aiop;

0 commit comments

Comments
 (0)