NNG_MSG_ALLOC(3)

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

✨ NNG_MSG_ALLOC(3) ✨

okay bestie, welcome to the NNG Reference Manual πŸŽ€ β€” this one's about the function that literally makes messages out of thin air. well, out of memory. same vibe tho πŸ’…


🌸 NAME 🌸

nng_msg_alloc β€” allocate a message 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <nng/nng.h>

int nng_msg_alloc(nng_msg **msgp, size_t size);

πŸ’– DESCRIPTION πŸ’–

so like. nng_msg_alloc() is the function you call when you need a brand-new message, and you need it to have a body that's size bytes long. it does the allocating, and then it drops the result into msgp so you can actually find it later. no cap. πŸ”₯

messages that come out of this function have a body and, optionally, a header. and like β€” those messages are the whole point, because they're the things you use with all your receive and transmit functions. it's giving main character energy honestly πŸ‘‘


⭐ RETURN VALUES ⭐

it returns 0 when everything slays, and non-zero when it does not. periodt. πŸ’…


🌈 ERRORS 🌈

  • NNG_ENOMEM β€” there is not enough free memory lying around to allocate a message. tragic. 😭 no memory, no message, that's the whole deal.

🧚 SEE ALSO 🧚

nng_msg_free(3), nng_msg_body(3), nng_msg_dup(3), nng_msg_header(3), nng_msg_header_len(3), nng_msg_len(3), nng_msg_capacity(3), nng_msg_reserve(3), nng_msg_realloc(3), nng_strerror(3), nng_msg(5), nng(7)

go read nng_msg_free(3) next, bestie. you allocated it, now you have to free it. that's the circle of life fr fr πŸ¦‹ don't leak, that's not iconic.

and that's the whole page!! this came from the NNG Reference Manual, dated 2026-06-30, and it's NNG_MSG_ALLOC(3) β€” mwah, obsessed πŸ’–βœ¨

πŸ“¦ where this page comes from