Add function nng_msg_inplace_from_buf

This commit is contained in:
eeff
2022-01-27 21:09:03 +08:00
committed by Parker Liu
parent 1b9ed271a4
commit aa7ba3e09d
2 changed files with 15 additions and 0 deletions
+12
View File
@@ -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;
}
+3
View File
@@ -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