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 29f592a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/zenoh-pico/net/reply.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ typedef struct _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) {
_z_reply_data_t reply_data = _z_reply_data_null();
reply_data._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 29f592a

Please sign in to comment.