1ZMQ_MSG_INIT_DATA(3) 0MQ Manual ZMQ_MSG_INIT_DATA(3)
2
3
4
6 zmq_msg_init_data - initialise 0MQ message from a supplied buffer
7
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
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 functions zmq_msg_init(), zmq_msg_init_data() and
30 zmq_msg_init_size() are mutually exclusive. Never initialize the
31 same zmq_msg_t twice.
32
34 The zmq_msg_init_data() function shall return zero if successful.
35 Otherwise it shall return -1 and set errno to one of the values defined
36 below.
37
39 No errors are defined.
40
42 Initialising a message from a supplied buffer.
43
44 void my_free (void *data, void *hint)
45 {
46 free (data);
47 }
48
49 /* ... */
50
51 void *data = malloc (6);
52 assert (data);
53 memcpy (data, "ABCDEF", 6);
54 zmq_msg_t msg;
55 rc = zmq_msg_init_data (&msg, data, 6, my_free, NULL);
56 assert (rc == 0);
57
58
60 zmq_msg_init_size(3) zmq_msg_init(3) zmq_msg_close(3) zmq_msg_data(3)
61 zmq_msg_size(3) zmq(7)
62
64 This 0MQ manual page was written by Martin Sustrik
65 <sustrik@250bpm.com[1]> and Martin Lucina <mato@kotelna.sk[2]>.
66
68 1. sustrik@250bpm.com
69 mailto:sustrik@250bpm.com
70
71 2. mato@kotelna.sk
72 mailto:mato@kotelna.sk
73
74
75
760MQ 2.1.4 03/30/2011 ZMQ_MSG_INIT_DATA(3)