diff --git a/examples/unix/c11/z_get_attachment.c b/examples/unix/c11/z_get_attachment.c index da158e7f9..ca549a9e1 100644 --- a/examples/unix/c11/z_get_attachment.c +++ b/examples/unix/c11/z_get_attachment.c @@ -46,7 +46,7 @@ typedef struct kv_pairs_rx_t { static z_condvar_t cond; static z_mutex_t mutex; -size_t kv_pairs_length(kv_pairs_tx_t *kvp) { +size_t kv_pairs_size(kv_pairs_tx_t *kvp) { size_t ret = 0; for (size_t i = 0; i < kvp->len; i++) { // Size fields @@ -219,7 +219,7 @@ int main(int argc, char **argv) { kvs[0] = (kv_pair_t){.key = "test_key", .value = "test_value"}; kv_pairs_tx_t ctx = (kv_pairs_tx_t){.data = kvs, .current_idx = 0, .len = 1}; z_owned_bytes_t attachment; - zp_bytes_encode_from_iter(&attachment, create_attachment_iter, (void *)&ctx, kv_pairs_length(&ctx)); + zp_bytes_encode_from_iter(&attachment, create_attachment_iter, (void *)&ctx, kv_pairs_size(&ctx)); opts.attachment = z_move(attachment); z_owned_closure_reply_t callback; diff --git a/examples/unix/c11/z_pub_attachment.c b/examples/unix/c11/z_pub_attachment.c index 50bc1c106..4f7f30168 100644 --- a/examples/unix/c11/z_pub_attachment.c +++ b/examples/unix/c11/z_pub_attachment.c @@ -35,7 +35,8 @@ typedef struct kv_pairs_t { #if Z_FEATURE_PUBLICATION == 1 -size_t kv_pairs_length(kv_pairs_t *kvp) { +// Return the total serialized size of the key value pairs +size_t kv_pairs_size(kv_pairs_t *kvp) { size_t ret = 0; for (size_t i = 0; i < kvp->len; i++) { // Size fields @@ -162,7 +163,7 @@ int main(int argc, char **argv) { sprintf(buf_ind, "%d", idx); kvs[1] = (kv_pair_t){.key = "index", .value = buf_ind}; kv_pairs_t ctx = (kv_pairs_t){.data = kvs, .current_idx = 0, .len = 2}; - zp_bytes_encode_from_iter(&attachment, create_attachment_iter, (void *)&ctx, kv_pairs_length(&ctx)); + zp_bytes_encode_from_iter(&attachment, create_attachment_iter, (void *)&ctx, kv_pairs_size(&ctx)); options.attachment = z_move(attachment); sprintf(buf, "[%4d] %s", idx, value); diff --git a/examples/unix/c11/z_queryable_attachment.c b/examples/unix/c11/z_queryable_attachment.c index d6b41fac2..6c6ecc1ef 100644 --- a/examples/unix/c11/z_queryable_attachment.c +++ b/examples/unix/c11/z_queryable_attachment.c @@ -47,7 +47,7 @@ const char *keyexpr = "demo/example/zenoh-pico-queryable"; const char *value = "Queryable from Pico!"; static int msg_nb = 0; -size_t kv_pairs_length(kv_pairs_tx_t *kvp) { +size_t kv_pairs_size(kv_pairs_tx_t *kvp) { size_t ret = 0; for (size_t i = 0; i < kvp->len; i++) { // Size fields @@ -141,7 +141,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { kvs[0] = (kv_pair_t){.key = "reply_key", .value = "reply_value"}; kv_pairs_tx_t kv_ctx = (kv_pairs_tx_t){.data = kvs, .current_idx = 0, .len = 1}; z_owned_bytes_t attachment; - zp_bytes_encode_from_iter(&attachment, create_attachment_iter, (void *)&kv_ctx, kv_pairs_length(&kv_ctx)); + zp_bytes_encode_from_iter(&attachment, create_attachment_iter, (void *)&kv_ctx, kv_pairs_size(&kv_ctx)); options.attachment = z_move(attachment); z_query_reply(query, z_query_keyexpr(query), z_move(reply_payload), &options);