ZMQ_MSG_INIT_BUFFER(3)

πŸ’– ZMQ_MSG_INIT_BUFFER(3) πŸ’–

okay bestie, welcome to the 0MQ Manual ✨ this is the page for zmq_msg_init_buffer, and it's literally the glow-up your message needs. sit down, hydrate, let's go 🫢


🌸 NAME 🌸

zmq_msg_init_buffer β€” initialise a 0MQ message with a copy of a buffer πŸ’…


✨ SYNOPSIS ✨

int zmq_msg_init_buffer (zmq_msg_t *msg, const void *buf, size_t size);

πŸŽ€ DESCRIPTION πŸŽ€

so the way that zmq_msg_init_buffer() works is: it shall allocate every resource it needs to store a message that's size bytes long, and then it initialises the message object that msg points to so it represents a copy of the buffer that the buf and size arguments are pointing at. copy, not borrow. she's her own girl πŸ’–

and the implementation gets to choose for itself whether it stores the message content on the stack (for small messages) or on the heap (for large messages). it's giving "trust the implementation, she knows her limits" ✨

⚠️ Caution β€” never ever access zmq_msg_t members directly. like, not even once. always use the zmq_msg family of functions instead. no peeking under the hood, bestie πŸ™ˆ
⚠️ Caution β€” the functions zmq_msg_init(), zmq_msg_init_data(), zmq_msg_init_buffer() and zmq_msg_init_buffer() are mutually exclusive. never initialise the same zmq_msg_t twice. fr fr. double-initialising is not the vibe, it's a whole situation πŸ’€

🌈 RETURN VALUE 🌈

zmq_msg_init_buffer() shall return zero if everything's cute and successful. otherwise it shall return -1 and set errno to one of the values listed below. she will tell you what went wrong, you just gotta listen πŸ‘‘


πŸ¦‹ ERRORS πŸ¦‹

  • ENOMEM β€” insufficient storage space is available. like, there is simply no room, the closet is full, we cannot make it work 😭

πŸ‘‘ SEE ALSO πŸ‘‘

zmq_msg_init_data(3) zmq_msg_init_size(3) zmq_msg_init(3) zmq_msg_close(3) zmq_msg_data(3) zmq_msg_size(3) zmq(7)


πŸ’œ AUTHORS πŸ’œ

this page was written by the 0MQ community 🫢 and if you wanna make a change, please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. they'd love to have you, no cap πŸ’…


0MQ 4.3.5 Β· 10/09/2023 Β· that's the whole page bestie, mwah πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from