7
zmq_msg_init_data - initialise 0MQ message from a supplied buffer
12
*typedef void (zmq_free_fn) (void '*data', void '*hint');*
14
*int zmq_msg_init_data (zmq_msg_t '*msg', void '*data', size_t 'size', zmq_free_fn '*ffn', void '*hint');*
19
The _zmq_msg_init_data()_ function shall initialise the message object
20
referenced by 'msg' to represent the content referenced by the buffer located
21
at address 'data', 'size' bytes long. No copy of 'data' shall be performed and
22
0MQ shall take ownership of the supplied buffer.
24
If provided, the deallocation function 'ffn' shall be called once the data
25
buffer is no longer required by 0MQ, with the 'data' and 'hint' arguments
26
supplied to _zmq_msg_init_data()_.
28
CAUTION: Never access 'zmq_msg_t' members directly, instead always use the
29
_zmq_msg_ family of functions.
31
CAUTION: The deallocation function 'ffn' needs to be thread-safe, since it
32
will be called from an arbitrary thread.
34
CAUTION: The functions _zmq_msg_init()_, _zmq_msg_init_data()_ and
35
_zmq_msg_init_size()_ are mutually exclusive. Never initialize the same
41
The _zmq_msg_init_data()_ function shall return zero if successful. Otherwise
42
it shall return `-1` and set 'errno' to one of the values defined below.
48
Insufficient storage space is available.
54
.Initialising a message from a supplied buffer
56
void my_free (void *data, void *hint)
63
void *data = malloc (6);
65
memcpy (data, "ABCDEF", 6);
67
rc = zmq_msg_init_data (&msg, data, 6, my_free, NULL);
74
linkzmq:zmq_msg_init_size[3]
75
linkzmq:zmq_msg_init[3]
76
linkzmq:zmq_msg_close[3]
77
linkzmq:zmq_msg_data[3]
78
linkzmq:zmq_msg_size[3]
84
The 0MQ documentation was written by Martin Sustrik <sustrik@250bpm.com> and
85
Martin Lucina <martin@lucina.net>.