NN_REALLOCMSG(3)

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

✨ NN_REALLOCMSG ✨

okay bestie, pull up a chair πŸ’– this is the nn_reallocmsg page from the nanomsg manual, section 3, and it's literally the glow-up-your-message function. let's get into it.


🌸 NAME 🌸

nn_reallocmsg β€” reallocate a message. that's it, that's the whole vibe. resize szn πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <nanomsg/nn.h>

void *nn_reallocmsg (void *msg, size_t size);

yes queen, that's the signature. void * in, void * out, size_t size for the new size. no cap. ✨


πŸ’œ DESCRIPTION πŸ’œ

so here's the tea πŸ«– β€” this function reallocates a message that was previously allocated by nn_allocmsg(3), or that you received from a peer using the NN_MSG mechanism.

basically: you got a message, and now you want it to be a different size. this is the function for that. main character energy fr fr πŸ‘‘

⚠️ important bestie β€” just like the standard realloc, this operation may involve copying the data in the buffer. so like, it's not always an in-place glow-up. the data might get moved. the way that realloc works... yeah. lowkey iconic, highkey worth knowing. 😭

πŸŽ€ RETURN VALUE πŸŽ€

  • if the function succeeds, you get a pointer to the newly allocated buffer back. slay πŸ’…
  • otherwise, NULL is returned and errno is set to one of the values defined below. not the vibe, but okay. πŸ’€

πŸ”₯ ERRORS πŸ”₯

  • ENOMEM β€” not enough memory to allocate the message. the machine said no. πŸ“

🌈 EXAMPLE 🌈

here's the whole thing in action, bestie:

void *buf = nn_allocmsg (12, 0);
void *newbuf = nn_reallocmsg (buf, 20);
nn_freemsg (newbuf);

allocate 12, realloc to 20, free it. clean, simple, periodt. ✨


πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, i'm obsessed with them:


πŸ’– AUTHORS πŸ’–

  • Martin Sustrik <sustrik@250bpm.com>

and that's the whole page, bestie!! 🫢 this was nanomsg version 1.2.2, dated 2026-01-16, and yeah β€” the manual name was NN_REALLOCMSG(3) the whole time, iykyk. now go reallocate something responsibly. mwah. πŸ’…πŸ§šπŸ’œ

πŸ“¦ where this page comes from