NN_ALLOCMSG(3compat)

πŸ“¦ version 1.11, in alpine 3.24

✨ NAME ✨

nn_allocmsg β€” the way you allocate a message (it's the compatible API, bestie πŸ’…)

This one lives in the 3compat crew, straight out of the NNG Reference Manual β€” so yes, it's the throwback-compatible version, and it still eats.


🌸 SYNOPSIS 🌸

#include <nanomsg/nn.h>

void *nn_allocmsg(size_t size, int type);

πŸ’– DESCRIPTION πŸ’–

Okay so nn_allocmsg() allocates a whole message structure of size size, and the way it really pops is that it's primarily used to support zero-copy send operations β€” literally its main character moment β€” by making use of the NNG_MSG special size indicator. The value it hands back is a pointer to the start of the message payload buffer. πŸŽ€

Your size has to be positive, and small enough to hold reasonable message data plus book-keeping information. Not too teeny, not too extra. Balance. 🧚

Note 🫢 This function is here for API compatibility with legacy libnanomsg. Consider using the relevant modern API instead β€” ngl, the new stuff is kind of iconic.

And type? It must be zero. Like, zero zero. This argument was reserved to support different kinds of memory spaces for RDMA devices, but that was never developed in the legacy API β€” so it's just sitting there being zero forever. 😭

When you're done with the message you got back, you have to dispose of it β€” either with nn_freemsg() or nn_send(). Don't just leave it there, that's not the vibe. πŸ—‘οΈ


🫢 RETURN VALUES 🫢

This function returns a pointer to message buffer space, or NULL on failure. That's the whole deal β€” pointer = slay, NULL = something went wrong. πŸ’€


πŸ’… ERRORS πŸ’…

  • ENOMEM β€” insufficient memory is available. The memory said no. πŸ™ˆ
  • EINVAL β€” an invalid size or type was specified. You gave it something it can't work with, bestie.
  • ETERM β€” the library is shutting down. It's logging off, respectfully. ✨

πŸ¦‹ SEE ALSO πŸ¦‹


Okay that's the whole page, bestie β€” go allocate something gorgeous πŸ’œ This was the NNG Reference Manual entry NN_ALLOCMSG(3compat), and it's dated 2026-01-13. Periodt. πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from