Skip to content

Commit

Permalink
rename _z_xxx_alias into _z_xxx_stead_data to better reflect for the …
Browse files Browse the repository at this point in the history
…functions do
  • Loading branch information
DenisBiryukov91 committed Mar 3, 2025
1 parent 88d4b31 commit b110653
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
5 changes: 3 additions & 2 deletions include/zenoh-pico/net/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ typedef struct {
// Warning: None of the sub-types require a non-0 initialization. Add a init function if it changes.
static inline _z_queryable_t _z_queryable_null(void) { return (_z_queryable_t){0}; }
static inline bool _z_queryable_check(const _z_queryable_t *queryable) { return !_Z_RC_IS_NULL(&queryable->_zn); }
static inline _z_query_t _z_query_alias(_z_value_t *value, _z_keyexpr_t *key, _z_slice_t *parameters,
_z_session_rc_t *zn, uint32_t request_id, _z_bytes_t *attachment, bool anyke) {
static inline _z_query_t _z_query_steal_data(_z_value_t *value, _z_keyexpr_t *key, _z_slice_t *parameters,
const _z_session_rc_t *zn, uint32_t request_id, _z_bytes_t *attachment,
bool anyke) {
_z_query_t ret;
ret._key = _z_keyexpr_steal(key);
ret._value = _z_value_steal(value);
Expand Down
10 changes: 5 additions & 5 deletions include/zenoh-pico/net/reply.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ typedef struct _z_reply_t {

// Warning: None of the sub-types require a non-0 initialization. Add a init function if it changes.
static inline _z_reply_t _z_reply_null(void) { return (_z_reply_t){0}; }
static inline _z_reply_t _z_reply_alias(_z_keyexpr_t *keyexpr, _z_id_t id, _z_bytes_t *payload,
const _z_timestamp_t *timestamp, _z_encoding_t *encoding, z_sample_kind_t kind,
_z_bytes_t *attachment) {
static inline _z_reply_t _z_reply_steal_data(_z_keyexpr_t *keyexpr, _z_id_t id, _z_bytes_t *payload,
const _z_timestamp_t *timestamp, _z_encoding_t *encoding,
z_sample_kind_t kind, _z_bytes_t *attachment) {
_z_reply_t r;
r.data.replier_id = id;
r.data._tag = _Z_REPLY_TAG_DATA;
r.data._result.sample = _z_sample_alias(keyexpr, payload, timestamp, encoding, kind, _Z_N_QOS_DEFAULT, attachment,
Z_RELIABILITY_DEFAULT);
r.data._result.sample = _z_sample_steal_data(keyexpr, payload, timestamp, encoding, kind, _Z_N_QOS_DEFAULT,
attachment, Z_RELIABILITY_DEFAULT);
return r;
}
static inline _z_reply_t _z_reply_err_alias(_z_bytes_t *payload, _z_encoding_t *encoding) {
Expand Down
6 changes: 3 additions & 3 deletions include/zenoh-pico/net/sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ static inline bool _z_sample_check(const _z_sample_t *sample) {
return _z_keyexpr_check(&sample->keyexpr) || _z_encoding_check(&sample->encoding) ||
_z_bytes_check(&sample->payload) || _z_bytes_check(&sample->attachment);
}
static inline _z_sample_t _z_sample_alias(_z_keyexpr_t *key, _z_bytes_t *payload, const _z_timestamp_t *timestamp,
_z_encoding_t *encoding, z_sample_kind_t kind, _z_qos_t qos,
_z_bytes_t *attachment, z_reliability_t reliability) {
static inline _z_sample_t _z_sample_steal_data(_z_keyexpr_t *key, _z_bytes_t *payload, const _z_timestamp_t *timestamp,
_z_encoding_t *encoding, z_sample_kind_t kind, _z_qos_t qos,
_z_bytes_t *attachment, z_reliability_t reliability) {
_z_sample_t ret;
ret.keyexpr = _z_keyexpr_steal(key);
ret.payload = _z_bytes_steal(payload);
Expand Down
4 changes: 2 additions & 2 deletions src/session/liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ z_result_t _z_liveliness_pending_query_reply(_z_session_t *zn, uint32_t interest
_z_encoding_t encoding = _z_encoding_null();
_z_bytes_t payload = _z_bytes_null();
_z_bytes_t attachment = _z_bytes_null();
_z_reply_t reply = _z_reply_alias(&expanded_ke, zn->_local_zid, &payload, timestamp, &encoding,
Z_SAMPLE_KIND_PUT, &attachment);
_z_reply_t reply = _z_reply_steal_data(&expanded_ke, zn->_local_zid, &payload, timestamp, &encoding,
Z_SAMPLE_KIND_PUT, &attachment);

pq->_callback(&reply, pq->_arg);
_z_reply_clear(&reply);
Expand Down
4 changes: 2 additions & 2 deletions src/session/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ static z_result_t _z_trigger_query_reply_partial_inner(_z_session_t *zn, const _
return _Z_ERR_QUERY_NOT_MATCH;
}
// Build the reply
_z_reply_t reply = _z_reply_alias(&expanded_ke, zn->_local_zid, &msg->_payload, &msg->_commons._timestamp,
&msg->_encoding, kind, &msg->_attachment);
_z_reply_t reply = _z_reply_steal_data(&expanded_ke, zn->_local_zid, &msg->_payload, &msg->_commons._timestamp,
&msg->_encoding, kind, &msg->_attachment);
// Process monotonic & latest consolidation mode
if ((pen_qry->_consolidation == Z_CONSOLIDATION_MODE_LATEST) ||
(pen_qry->_consolidation == Z_CONSOLIDATION_MODE_MONOTONIC)) {
Expand Down
2 changes: 1 addition & 1 deletion src/session/queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static z_result_t _z_session_queryable_get_infos(_z_session_t *zn, _z_queryable_
static inline void _z_queryable_query_steal_data(_z_query_t *query, _z_session_rc_t *zsrc, _z_msg_query_t *msgq,
_z_keyexpr_t *key, uint32_t qid, bool anyke) {
// Steal received data in query
*query = _z_query_alias(&msgq->_ext_value, key, &msgq->_parameters, zsrc, qid, &msgq->_ext_attachment, anyke);
*query = _z_query_steal_data(&msgq->_ext_value, key, &msgq->_parameters, zsrc, qid, &msgq->_ext_attachment, anyke);
}

static z_result_t _z_trigger_queryables_inner(_z_session_rc_t *zsrc, _z_msg_query_t *msgq, _z_keyexpr_t *q_key,
Expand Down
4 changes: 2 additions & 2 deletions src/session/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ static z_result_t _z_trigger_subscriptions_inner(_z_session_t *zn, _z_subscriber
_Z_DEBUG("Triggering %ju subs for key %d - %.*s", (uintmax_t)sub_infos.sub_nb, sub_infos.ke_out._id,
(int)_z_string_len(&sub_infos.ke_out._suffix), _z_string_data(&sub_infos.ke_out._suffix));
// Create sample
_z_sample_t sample =
_z_sample_alias(&sub_infos.ke_out, payload, timestamp, encoding, sample_kind, qos, attachment, reliability);
_z_sample_t sample = _z_sample_steal_data(&sub_infos.ke_out, payload, timestamp, encoding, sample_kind, qos,
attachment, reliability);

z_result_t ret = _Z_RES_OK;
// Parse subscription infos svec
Expand Down

0 comments on commit b110653

Please sign in to comment.