NNG_MSG_ALLOC(3)
β¨ 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
- 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