mirror of
https://github.com/emqx/neuron.git
synced 2026-10-29 15:09:11 +08:00
Add function nng_msg_inplace_from_buf
This commit is contained in:
@@ -149,3 +149,15 @@ void *msg_get_buf_ptr(message_t *msg)
|
||||
return msg->inp_buf.buf_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
nng_msg *nng_msg_inplace_from_buf(msg_type_e msg_type, void *buf, size_t size)
|
||||
{
|
||||
nng_msg *msg = NULL;
|
||||
size_t msg_size = msg_inplace_data_get_size(size);
|
||||
int rv = nng_msg_alloc(&msg, msg_size);
|
||||
if (rv == 0) {
|
||||
message_t *msg_ptr = nng_msg_body(msg);
|
||||
msg_with_struct_init(msg_ptr, msg_type, buf, size);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -216,4 +216,7 @@ void msg_external_data_uninit(message_t *msg);
|
||||
msg_type_e msg_get_type(message_t *msg);
|
||||
size_t msg_get_buf_len(message_t *msg);
|
||||
void * msg_get_buf_ptr(message_t *msg);
|
||||
|
||||
nng_msg *nng_msg_inplace_from_buf(msg_type_e msg_type, void *buf, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user