ZMQ_MSG_INIT_SIZE(3)

πŸ’– zmq_msg_init_size β€” bestie edition πŸ’–

okay so you're in the 0MQ manual (that's ZeroMQ, the messaging library, hi πŸ‘‹) and you clicked on zmq_msg_init_size. slay. let's get into it 🫢


✨ NAME ✨

zmq_msg_init_size β€” initialise a 0MQ message of a specified size πŸ’…


✨ SYNOPSIS ✨

int zmq_msg_init_size (zmq_msg_t *msg, size_t size);

✨ DESCRIPTION ✨

So zmq_msg_init_size() shall allocate literally every resource you need to store a message that's size bytes long, and then it initialises the message object that msg points to, so that it represents that freshly allocated message. new message, who dis πŸ’–

The implementation gets to choose whether it stores the message content on the stack (for small messages, cute and cozy) or on the heap (for large messages, main character storage energy). It's the implementation's call, not yours, bestie.

And for performance reasons? zmq_msg_init_size() shall not clear the message data. That's not a bug, that's a feature β€” it's not gonna waste time zeroing stuff out for you. So don't be surprised when the bytes are just… whatever they are. πŸ™ˆ

⚠️ Caution ⚠️ Never access zmq_msg_t members directly, bestie, I am begging. Always use the zmq_msg family of functions. no cap, that's the rule πŸ‘‘
⚠️ Caution ⚠️ The functions zmq_msg_init(), zmq_msg_init_data(), zmq_msg_init_size() and zmq_msg_init_buffer() are mutually exclusive. Never initialise the same zmq_msg_t twice. like. never ever. it's giving undefined behaviour and we do not want that πŸ’€

✨ RETURN VALUE ✨

zmq_msg_init_size() shall return zero if it succeeded πŸŽ‰ otherwise it shall return -1 and set errno to one of the values defined below. sad girl hours, but at least you get an errno 😭


✨ ERRORS ✨

  • ENOMEM β€” Insufficient storage space is available. the vibes are simply not there, there's no room πŸ’”

✨ SEE ALSO ✨


✨ AUTHORS ✨

This page was written by the 0MQ community 🫢 (yes, the whole community, iconic behaviour). If you wanna make a change, please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing before you go feral in the repo, okurrr? 🌈


and that's the whole page, bestie β€” you ate that πŸ’…βœ¨

this was page ZMQ_MSG_INIT_SIZE(3) from 0MQ version 4.3.5, dated 10/09/2023 πŸŽ€

πŸ“¦ where this page comes from