From dbbee1a3ea7fbd26c528eb96ebe0dbfd7075e292 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 10 Aug 2017 18:14:27 -0700 Subject: Unify the msg API. This makes the operations that work on headers start with nni_msg_header or nng_msg_header. It also renames _trunc to _chop (same strlen as _trim), and renames prepend to insert. We add a shorthand for clearing message content, and make better use of the endian safe 32-bit accessors too. This also fixes a bug in inserting large headers into messages. A test suite for message handling is included. --- src/nng_compat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nng_compat.c') diff --git a/src/nng_compat.c b/src/nng_compat.c index dfcb2134..710be9be 100644 --- a/src/nng_compat.c +++ b/src/nng_compat.c @@ -345,7 +345,7 @@ nn_recvmsg(int s, struct nn_msghdr *mh, int flags) if ((mh->msg_iovlen == 1) && (mh->msg_iov[0].iov_len == NN_MSG)) { // Receiver wants to have a dynamically allocated message. // There can only be one of these. - if ((rv = nng_msg_prepend(msg, &msg, sizeof(msg))) != 0) { + if ((rv = nng_msg_insert(msg, &msg, sizeof(msg))) != 0) { nng_msg_free(msg); nn_seterror(rv); return (-1); @@ -534,7 +534,7 @@ nn_sendmsg(int s, const struct nn_msghdr *mh, int flags) continue; } data += sizeof(spsz); - rv = nng_msg_append_header(msg, data, spsz); + rv = nng_msg_header_append(msg, data, spsz); if (rv != 0) { if (!keep) { nng_msg_free(msg); -- cgit v1.2.3-70-g09d2