Skip to content

Commit

Permalink
feat: add reply_data_init function
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Oct 11, 2024
1 parent 9c29166 commit e06a1cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/zenoh-pico/net/reply.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ typedef struct _z_reply_data_t {
} _z_reply_data_t;

// Warning: None of the sub-types require a non-0 initialization. Add a init function if it changes.
static inline _z_reply_data_t _z_reply_data_null(void) { return (_z_reply_data_t){0}; }
static inline _z_reply_data_t _z_reply_data_init(void) {
return (_z_reply_data_t){.replier_id = {.id = {0}}, ._result.sample = _z_sample_null(), ._tag = _Z_REPLY_TAG_NONE};
}
void _z_reply_data_clear(_z_reply_data_t *rd);
z_result_t _z_reply_data_copy(_z_reply_data_t *dst, const _z_reply_data_t *src);

Expand Down
4 changes: 2 additions & 2 deletions src/net/reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ void _z_reply_data_free(_z_reply_data_t **reply_data) {
}

z_result_t _z_reply_data_copy(_z_reply_data_t *dst, const _z_reply_data_t *src) {
*dst = _z_reply_data_null();
dst->_tag = src->_tag;
*dst = _z_reply_data_init();
if (src->_tag == _Z_REPLY_TAG_DATA) {
_Z_RETURN_IF_ERR(_z_sample_copy(&dst->_result.sample, &src->_result.sample));
} else if (src->_tag == _Z_REPLY_TAG_ERROR) {
_Z_RETURN_IF_ERR(_z_value_copy(&dst->_result.error, &src->_result.error));
}
dst->_tag = src->_tag;
dst->replier_id = src->replier_id;
return _Z_RES_OK;
}
Expand Down

0 comments on commit e06a1cb

Please sign in to comment.