Skip to content

Commit

Permalink
fix: rename kv_pairs_length
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Jun 17, 2024
1 parent a488558 commit dbd71b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/unix/c11/z_get_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions examples/unix/c11/z_pub_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c11/z_queryable_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit dbd71b6

Please sign in to comment.