ZMQ_MSG_COPY(3)
π ZMQ_MSG_COPY π
okay so bestie, we're in the 0MQ Manual today and this one is literally called zmq_msg_copy β she copies the content of a message to another message. that's it, that's the girl. π
β¨ NAME β¨
zmq_msg_copy β copy content of a message to another message π«Ά
πΈ SYNOPSIS πΈ
int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src);
π¦ DESCRIPTION π¦
So like, zmq_msg_copy() shall copy the message object that src is pointing at, and drop it into the message object that dest is pointing at. The original content of dest, if there even is any, shall be released β like, gone, released, bye. π
IMPORTANT: you must initialise dest before copying to it. no initialising, no copying. periodt.
π¨ Caution #1 π¨
The implementation may choose not to physically copy the message content β instead it may share the underlying buffer between src and dest. lowkey iconic of it but also kinda scary. π
Avoid modifying message content after a message has been copied with zmq_msg_copy(), because doing so can result in undefined behaviour. fr fr, do not do it.
If what you actually need is a real, honest-to-god hard copy, initialize a new message using zmq_msg_init_buffer() with the message content. that's the move. π
π¨ Caution #2 π¨
Never access zmq_msg_t members directly. like, ever. instead always use the zmq_msg family of functions. they're your besties, let them handle it. π
π RETURN VALUE π
The zmq_msg_copy() function shall return zero if successful. slay. β¨
Otherwise it shall return -1 and set errno to one of the values defined below. not slay. π
π ERRORS π
EFAULTβ Invalid message. π
β EXAMPLE β
Copying a message. look at her go:
zmq_msg_t msg;
zmq_msg_init_buffer (&msg, "Hello, World", 12);
zmq_msg_t copy;
zmq_msg_init (©);
zmq_msg_copy (©, &msg);
...
zmq_msg_close (©);
zmq_msg_close (&msg);
π SEE ALSO π
zmq_msg_move(3) zmq_msg_init(3) zmq_msg_init_size(3) zmq_msg_init_buffer(3) zmq_msg_init_data(3) zmq_msg_close(3) zmq(7)
π AUTHORS π
This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. π
and that's the whole vibe check bestie β 0MQ 4.3.5, dated 10/09/2023, iykyk π§β¨
π¦ where this page comes from
- epel 10: zeromq 4.3.5-18.el10_0 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 43: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 43: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 44: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 44: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms