1ZMQ_MSG_INIT_DATA(3)              0MQ Manual              ZMQ_MSG_INIT_DATA(3)
2
3
4

NAME

6       zmq_msg_init_data - initialise 0MQ message from a supplied buffer
7

SYNOPSIS

9       typedef void (zmq_free_fn) (void *data, void *hint);
10
11       int zmq_msg_init_data (zmq_msg_t *msg, void *data, size_t size,
12       zmq_free_fn *ffn, void *hint);
13

DESCRIPTION

15       The zmq_msg_init_data() function shall initialise the message object
16       referenced by msg to represent the content referenced by the buffer
17       located at address data, size bytes long. No copy of data shall be
18       performed and 0MQ shall take ownership of the supplied buffer.
19
20       If provided, the deallocation function ffn shall be called once the
21       data buffer is no longer required by 0MQ, with the data and hint
22       arguments supplied to zmq_msg_init_data().
23
24           Caution
25           Never access zmq_msg_t members directly, instead always use the
26           zmq_msg family of functions.
27
28           Caution
29           The deallocation function ffn needs to be thread-safe, since it
30           will be called from an arbitrary thread.
31
32           Caution
33           If the deallocation function is not provided, the allocated memory
34           will not be freed, and this may cause a memory leak.
35
36           Caution
37           The functions zmq_msg_init(), zmq_msg_init_data(),
38           zmq_msg_init_size() and zmq_msg_init_buffer() are mutually
39           exclusive. Never initialise the same zmq_msg_t twice.
40

RETURN VALUE

42       The zmq_msg_init_data() function shall return zero if successful.
43       Otherwise it shall return -1 and set errno to one of the values defined
44       below.
45

ERRORS

47       ENOMEM
48           Insufficient storage space is available.
49

EXAMPLE

51       Initialising a message from a supplied buffer.
52
53           void my_free (void *data, void *hint)
54           {
55               free (data);
56           }
57
58               /*  ...  */
59
60           void *data = malloc (6);
61           assert (data);
62           memcpy (data, "ABCDEF", 6);
63           zmq_msg_t msg;
64           rc = zmq_msg_init_data (&msg, data, 6, my_free, NULL);
65           assert (rc == 0);
66
67

SEE ALSO

69       zmq_msg_init_size(3) zmq_msg_init_buffer(3) zmq_msg_init(3)
70       zmq_msg_close(3) zmq_msg_data(3) zmq_msg_size(3) zmq(7)
71

AUTHORS

73       This page was written by the 0MQ community. To make a change please
74       read the 0MQ Contribution Policy at
75       http://www.zeromq.org/docs:contributing.
76
77
78
790MQ 4.3.4                         07/22/2023              ZMQ_MSG_INIT_DATA(3)
Impressum