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. Thanks. 11.05.2011, 19:03, "Ivan Pechorin" <ivan.pecho...@gmail.com>: > 2011/5/11 Dirkjan Ochtman <dirk...@ochtman.nl>;: > >>> Is the code >>> == >>> zmq_msg_t msg; >>> zmq_msg_init_data (&msg, (void *)"something", 9, NULL, NULL); >>> == >>> valid? >> 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@lists.zeromq.org > http://lists.zeromq.org/mailman/listinfo/zeromq-dev -- Best regards, Ilja Golshtein. _______________________________________________ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev