Skip to content

Commit

Permalink
fix: add svec_transfer function
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Jan 30, 2025
1 parent a4a9bf8 commit 2ca25bf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions include/zenoh-pico/collections/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ void _z_svec_release(_z_svec_t *v);
static inline z_result_t name##_svec_copy(name##_svec_t *dst, const name##_svec_t *src, bool use_elem_f) { \
return _z_svec_copy(dst, src, name##_elem_copy, sizeof(type), use_elem_f); \
} \
static inline name##_svec_t name##_svec_alias(const name##_svec_t *v, bool ownership) { \
return _z_svec_alias(v, ownership); \
static inline name##_svec_t name##_svec_alias(const name##_svec_t *v) { return _z_svec_alias(v, false); } \
static inline name##_svec_t name##_svec_transfer(name##_svec_t *v) { \
name##_svec_t ret = _z_svec_alias(v, true); \
v->_aliased = true; \
return ret; \
} \
static inline name##_svec_t name##_svec_alias_element(type *e) { return _z_svec_alias_element((void *)e); } \
static inline void name##_svec_move(name##_svec_t *dst, name##_svec_t *src) { _z_svec_move(dst, src); } \
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/codec/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ z_result_t _z_frame_decode(_z_t_msg_frame_t *msg, _z_zbuf_t *zbf, uint8_t header
msg_idx++;
}
// Alias network message svec in frame struct
msg->_messages = _z_network_message_svec_alias(msg_pool, false);
msg->_messages = _z_network_message_svec_alias(msg_pool);
return _Z_RES_OK;
}

Expand Down
4 changes: 2 additions & 2 deletions src/session/queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static z_result_t _z_session_queryable_get_infos(_z_session_t *zn, _z_queryable_
if (cache_entry != NULL) {
// Note cache entry
infos->ke_out = _z_keyexpr_alias(&cache_entry->ke_out);
infos->infos = _z_queryable_infos_svec_alias(&cache_entry->infos, false);
infos->infos = _z_queryable_infos_svec_alias(&cache_entry->infos);
infos->qle_nb = cache_entry->qle_nb;
} else {
// Build queryable data
Expand All @@ -183,7 +183,7 @@ static z_result_t _z_session_queryable_get_infos(_z_session_t *zn, _z_queryable_
#if Z_FEATURE_RX_CACHE == 1
// Update cache
_z_queryable_cache_data_t cache_storage = {
.infos = _z_queryable_infos_svec_alias(&infos->infos, true),
.infos = _z_queryable_infos_svec_transfer(&infos->infos),
.ke_in = _z_keyexpr_duplicate(&infos->ke_in),
.ke_out = _z_keyexpr_duplicate(&infos->ke_out),
.qle_nb = infos->qle_nb,
Expand Down
4 changes: 2 additions & 2 deletions src/session/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static z_result_t _z_subscription_get_infos(_z_session_t *zn, _z_subscriber_kind
// Note cache entry
if (cache_entry != NULL) {
infos->ke_out = _z_keyexpr_alias(&cache_entry->ke_out);
infos->infos = _z_subscription_infos_svec_alias(&cache_entry->infos, false);
infos->infos = _z_subscription_infos_svec_alias(&cache_entry->infos);
infos->sub_nb = cache_entry->sub_nb;
} else { // Construct data and add to cache
_Z_DEBUG("Resolving %d - %.*s on mapping 0x%x", infos->ke_in._id, (int)_z_string_len(&infos->ke_in._suffix),
Expand All @@ -227,7 +227,7 @@ static z_result_t _z_subscription_get_infos(_z_session_t *zn, _z_subscriber_kind
#if Z_FEATURE_RX_CACHE == 1
// Update cache, takes ownership of the data
_z_subscription_cache_data_t cache_storage = {
.infos = _z_subscription_infos_svec_alias(&infos->infos, true),
.infos = _z_subscription_infos_svec_transfer(&infos->infos),
.ke_in = _z_keyexpr_duplicate(&infos->ke_in),
.ke_out = _z_keyexpr_duplicate(&infos->ke_out),
.sub_nb = infos->sub_nb,
Expand Down

0 comments on commit 2ca25bf

Please sign in to comment.