reftable/block: rename `block_writer::buf` variable

Adapt the name of the `block_writer::buf` variable to instead be called `block`. This aligns it with the existing `block_len` variable, which tracks the length of this buffer, and is generally a bit more tied to the actual context where this variable gets used. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Nov 20, 2024 at 08:51 UTC aa248b8ab2ec0dd6e22373b504cfd4ec4b9b970a
2 files changed +14 -14
reftable/block.c
+10 -10
@@ -70,14 +70,14 @@ static int block_writer_register_restart(struct block_writer *w, int n,
70 return 0;
71 }
72
73 -int block_writer_init(struct block_writer *bw, uint8_t typ, uint8_t *buf,
73 +int block_writer_init(struct block_writer *bw, uint8_t typ, uint8_t *block,
74 uint32_t block_size, uint32_t header_off, int hash_size)
75 {
76 - bw->buf = buf;
76 + bw->block = block;
77 bw->hash_size = hash_size;
78 bw->block_size = block_size;
79 bw->header_off = header_off;
80 - bw->buf[header_off] = typ;
80 + bw->block[header_off] = typ;
81 bw->next = header_off + 4;
82 bw->restart_interval = 16;
83 bw->entries = 0;
@@ -95,7 +95,7 @@ int block_writer_init(struct block_writer *bw, uint8_t typ, uint8_t *buf,
95
96 uint8_t block_writer_type(struct block_writer *bw)
97 {
98 - return bw->buf[bw->header_off];
98 + return bw->block[bw->header_off];
99 }
100
101 /* Adds the reftable_record to the block. Returns -1 if it does not fit, 0 on
@@ -107,7 +107,7 @@ int block_writer_add(struct block_writer *w, struct reftable_record *rec)
107 struct reftable_buf last =
108 w->entries % w->restart_interval == 0 ? empty : w->last_key;
109 struct string_view out = {
110 - .buf = w->buf + w->next,
110 + .buf = w->block + w->next,
111 .len = w->block_size - w->next,
112 };
113
@@ -153,13 +153,13 @@ int block_writer_finish(struct block_writer *w)
153 {
154 int i;
155 for (i = 0; i < w->restart_len; i++) {
156 - put_be24(w->buf + w->next, w->restarts[i]);
156 + put_be24(w->block + w->next, w->restarts[i]);
157 w->next += 3;
158 }
159
160 - put_be16(w->buf + w->next, w->restart_len);
160 + put_be16(w->block + w->next, w->restart_len);
161 w->next += 2;
162 - put_be24(w->buf + 1 + w->header_off, w->next);
162 + put_be24(w->block + 1 + w->header_off, w->next);
163
164 /*
165 * Log records are stored zlib-compressed. Note that the compression
@@ -188,7 +188,7 @@ int block_writer_finish(struct block_writer *w)
188
189 w->zstream->next_out = w->compressed;
190 w->zstream->avail_out = compressed_len;
191 - w->zstream->next_in = w->buf + block_header_skip;
191 + w->zstream->next_in = w->block + block_header_skip;
192 w->zstream->avail_in = src_len;
193
194 /*
@@ -206,7 +206,7 @@ int block_writer_finish(struct block_writer *w)
206 * adjust the `next` pointer to point right after the
207 * compressed data.
208 */
209 - memcpy(w->buf + block_header_skip, w->compressed,
209 + memcpy(w->block + block_header_skip, w->compressed,
210 w->zstream->total_out);
211 w->next = w->zstream->total_out + block_header_skip;
212 }
reftable/block.h
+4 -4
@@ -22,7 +22,7 @@ struct block_writer {
22 unsigned char *compressed;
23 size_t compressed_cap;
24
25 - uint8_t *buf;
25 + uint8_t *block;
26 uint32_t block_size;
27
28 /* Offset of the global header. Nonzero in the first block only. */
@@ -43,9 +43,9 @@ struct block_writer {
43 };
44
45 /*
46 - * initializes the blockwriter to write `typ` entries, using `buf` as temporary
47 - * storage. `buf` is not owned by the block_writer. */
48 -int block_writer_init(struct block_writer *bw, uint8_t typ, uint8_t *buf,
46 + * initializes the blockwriter to write `typ` entries, using `block` as temporary
47 + * storage. `block` is not owned by the block_writer. */
48 +int block_writer_init(struct block_writer *bw, uint8_t typ, uint8_t *block,
49 uint32_t block_size, uint32_t header_off, int hash_size);
50
51 /* returns the block type (eg. 'r' for ref records. */