diff --git a/include/zenoh-pico/collections/vec.h b/include/zenoh-pico/collections/vec.h index 97c681d68..17cc759df 100644 --- a/include/zenoh-pico/collections/vec.h +++ b/include/zenoh-pico/collections/vec.h @@ -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); } \ diff --git a/src/protocol/codec/transport.c b/src/protocol/codec/transport.c index 5dfd01f0f..894fb41d8 100644 --- a/src/protocol/codec/transport.c +++ b/src/protocol/codec/transport.c @@ -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; } diff --git a/src/session/queryable.c b/src/session/queryable.c index 2f5e0ca79..e825e2333 100644 --- a/src/session/queryable.c +++ b/src/session/queryable.c @@ -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 @@ -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, diff --git a/src/session/subscription.c b/src/session/subscription.c index 90efd36af..10aa79b36 100644 --- a/src/session/subscription.c +++ b/src/session/subscription.c @@ -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), @@ -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,