diff options
author | Alistair Veitch <aveitch@google.com> | 2016-01-22 11:43:30 -0800 |
---|---|---|
committer | Alistair Veitch <aveitch@google.com> | 2016-01-22 11:43:30 -0800 |
commit | c45d088ae7d8f67f9422abc19562a81307bf78a2 (patch) | |
tree | 561a8b7a18051185d2d057a0a315cecb3323cd50 /src | |
parent | d409e3bf41d0102c7ab4370a5470c4259aad88a8 (diff) |
Single encode function
Diffstat (limited to 'src')
-rw-r--r-- | src/core/census/tag_set.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/core/census/tag_set.c b/src/core/census/tag_set.c index f573e909b3..b985eca52b 100644 --- a/src/core/census/tag_set.c +++ b/src/core/census/tag_set.c @@ -453,14 +453,21 @@ static size_t tag_set_encode(const struct tag_set *tags, char *buffer, return ENCODED_HEADER_SIZE + tags->kvm_used; } -size_t census_tag_set_encode_propagated(const census_tag_set *tags, - char *buffer, size_t buf_size) { - return tag_set_encode(&tags->tags[PROPAGATED_TAGS], buffer, buf_size); -} - -size_t census_tag_set_encode_propagated_binary(const census_tag_set *tags, - char *buffer, size_t buf_size) { - return tag_set_encode(&tags->tags[PROPAGATED_BINARY_TAGS], buffer, buf_size); +char *census_tag_set_encode(const census_tag_set *tags, char *buffer, + size_t *buf_size, size_t *bin_buf_size) { + size_t p_buf_size = + tag_set_encode(&tags->tags[PROPAGATED_TAGS], buffer, *buf_size); + if (p_buf_size == 0) { + return NULL; + } + char *b_buffer = buffer + p_buf_size; + *bin_buf_size = tag_set_encode(&tags->tags[PROPAGATED_BINARY_TAGS], b_buffer, + *buf_size - p_buf_size); + if (*bin_buf_size == 0) { + return NULL; + } + *buf_size = p_buf_size; + return b_buffer; } // Decode a tag set. |