NNG_MSG_INSERT(3)

πŸ“¦
version 1.12.0 Β· 4 versions
, in ubuntu stonking

πŸ’– 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 🌈


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