NNG_MSG_INSERT(3)
π NNG_MSG_INSERT(3) π
okay bestie, welcome to nng_msg_insert(3) from the NNG Reference Manual β this is the one where we shove bytes onto the FRONT of a message body. prepending era, truly. β¨
πΈ NAME πΈ
nng_msg_insert β prepend to message body π
β¨ SYNOPSIS β¨
#include <nng/nng.h>
int nng_msg_insert(nng_msg *msg, const void *val, size_t size);
int nng_msg_insert_u16(nng_msg *msg, uint16_t val16);
int nng_msg_insert_u32(nng_msg *msg, uint32_t val32);
int nng_msg_insert_u64(nng_msg *msg, uint64_t val64);
π¦ DESCRIPTION π¦
so the nng_msg_insert() family of functions prepends data to the front of the body of message msg, and it reallocates that message if it needs to. it's giving "make room, we're coming through". π
the first function, nng_msg_insert(), prepends size bytes and copies them from val. the rest of the squad β nng_msg_insert_u16(), nng_msg_insert_u32(), and nng_msg_insert_u64() β prepend the specified value (like val32) in network-byte order (aka big-endian). no cap, big-endian is the vibe here. π
Tip π‘ these functions make use of space that's pre-allocated in front of the message body if it's available, so they can often avoid doing any reallocation at all. literally the glow-up. applications should use these instead of reallocating and copying message content themselves, so they can benefit from this capability. don't do it by hand bestie, use the pre-allocated space, it's free real estate. π«Ά
π RETURN VALUES π
these functions return 0 on success, and non-zero otherwise. zero = slay, non-zero = we have a situation. π
π ERRORS π
NNG_ENOMEMβ insufficient free memory exists. π the memory said no. not enough room, babe.
π SEE ALSO π
nng_msg_alloc(3)nng_msg_append(3)nng_msg_body(3)nng_msg_chop(3)nng_msg_free(3)nng_msg_len(3)nng_msg_realloc(3)nng_msg_trim(3)nng_strerror(3)nng_msg(5)nng(7)
and that's the whole page, bestie!! this was the NNG Reference Manual version of NNG_MSG_INSERT(3), and this edition is serving 2026-06-30 energy. NNG_MSG_INSERT(3) forever, periodt. πβ¨ππ¦πΈπ
π«Άπ
π¦ where this page comes from
- ubuntu stonking: libnng-dev 1.12.0-1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms