NN_FREEMSG(3)

πŸ“¦
version 1.2.2 Β· 5 versions
, in fedora 44

πŸ’– NN_FREEMSG β€” deallocate a message πŸ’–

okay bestie, welcome to the nanomsg manual, page NN_FREEMSG(3), shipping with nanomsg 1.2.2 πŸŽ€ this is the one where we say bye-bye to a message and give that memory back. it's giving cleanup era. ✨


🌸 NAME 🌸

nn_freemsg β€” deallocate a message


✨ SYNOPSIS ✨

#include <nanomsg/nn.h>

int nn_freemsg (void *msg);

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, nn_freemsg deallocates a message. like, frees it. gone. bye. πŸ’…

which messages tho? the ones you got from nn_allocmsg(3), or the ones you received through nn_recv(3) or nn_recvmsg(3). those are the ones this function is for.

now, real talk: nn_recv(3) and nn_recvmsg(3) will absolutely let you receive data into whatever arbitrary buffer you want, no judgement. but using the library-allocated buffers? more efficient for large messages, bestie. why? because it lets you use zero-copy techniques. no copying, no extra work, just vibes and performance. πŸ”₯


πŸ‘‘ RETURN VALUE πŸ‘‘

  • if it works out? zero is returned. slay. ✨
  • if it does NOT work out? -1 is returned, and errno gets set to one of the values listed down below. 😭

πŸ’€ ERRORS πŸ’€

  • EFAULT β€” the message pointer is invalid. it's giving "that's not a real address" energy. 🚫

πŸ“ EXAMPLE πŸ“

here's the whole vibe, verbatim:

    void *buf;
    nn_recv (s, &buf, NN_MSG, 0);
    nn_freemsg (buf);

receive into buf, then free buf. clean, simple, iconic. 🌈


🫢 SEE ALSO 🫢


🧚 AUTHORS 🧚

Martin Sustrik <sustrik@250bpm.com> β€” the icon who wrote this, no cap. πŸ‘‘


mwah πŸ’– that's the whole page. this edition of the NN_FREEMSG(3) manual is from nanomsg 1.2.2, dated 2026-01-16. go free your messages, bestie, and hydrate. πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from