[zeromq-dev] zmq_msg_init_data with zero deallocation function
ilejncs at narod.ru
Wed May 11 17:26:49 CEST 2011
Although the note about stack is technically correct, the behaviour is undefined from C programming language standpoint.
I think it must be clearly stated the lifetime of the data must be controlled. In fact it must be kept until zeromq context closed, isn't it?
In zguide the zmq_msg_init_data syntax with zero ffn is used a couple of times, though I failed to find if it is explained
why it is wrong or at least dangerous.
11.05.2011, 19:03, "Ivan Pechorin" <ivan.pechorin at gmail.com>:
> 2011/5/11 Dirkjan Ochtman <dirkjan at ochtman.nl>;:
>>> Is the code
>>> zmq_msg_t msg;
>>> zmq_msg_init_data (&msg, (void *)"something", 9, NULL, NULL);
>> I think in this case "something" is allocated on the stack.
> It's more likely that it will be kept in read-only data section, not on stack.
> Therefore, the code snippet cited above should work fine.
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
More information about the zeromq-dev