Skip to content

Commit aa248b8

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 66ed011 commit aa248b8

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

reftable/block.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ static int block_writer_register_restart(struct block_writer *w, int n,
7070
return 0;
7171
}
7272

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,
7474
uint32_t block_size, uint32_t header_off, int hash_size)
7575
{
76-
bw->buf = buf;
76+
bw->block = block;
7777
bw->hash_size = hash_size;
7878
bw->block_size = block_size;
7979
bw->header_off = header_off;
80-
bw->buf[header_off] = typ;
80+
bw->block[header_off] = typ;
8181
bw->next = header_off + 4;
8282
bw->restart_interval = 16;
8383
bw->entries = 0;
@@ -95,7 +95,7 @@ int block_writer_init(struct block_writer *bw, uint8_t typ, uint8_t *buf,
9595

9696
uint8_t block_writer_type(struct block_writer *bw)
9797
{
98-
return bw->buf[bw->header_off];
98+
return bw->block[bw->header_off];
9999
}
100100

101101
/* 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)
107107
struct reftable_buf last =
108108
w->entries % w->restart_interval == 0 ? empty : w->last_key;
109109
struct string_view out = {
110-
.buf = w->buf + w->next,
110+
.buf = w->block + w->next,
111111
.len = w->block_size - w->next,
112112
};
113113

@@ -153,13 +153,13 @@ int block_writer_finish(struct block_writer *w)
153153
{
154154
int i;
155155
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]);
157157
w->next += 3;
158158
}
159159

160-
put_be16(w->buf + w->next, w->restart_len);
160+
put_be16(w->block + w->next, w->restart_len);
161161
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);
163163

164164
/*
165165
* Log records are stored zlib-compressed. Note that the compression
@@ -188,7 +188,7 @@ int block_writer_finish(struct block_writer *w)
188188

189189
w->zstream->next_out = w->compressed;
190190
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;
192192
w->zstream->avail_in = src_len;
193193

194194
/*
@@ -206,7 +206,7 @@ int block_writer_finish(struct block_writer *w)
206206
* adjust the `next` pointer to point right after the
207207
* compressed data.
208208
*/
209-
memcpy(w->buf + block_header_skip, w->compressed,
209+
memcpy(w->block + block_header_skip, w->compressed,
210210
w->zstream->total_out);
211211
w->next = w->zstream->total_out + block_header_skip;
212212
}

reftable/block.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct block_writer {
2222
unsigned char *compressed;
2323
size_t compressed_cap;
2424

25-
uint8_t *buf;
25+
uint8_t *block;
2626
uint32_t block_size;
2727

2828
/* Offset of the global header. Nonzero in the first block only. */
@@ -43,9 +43,9 @@ struct block_writer {
4343
};
4444

4545
/*
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,
4949
uint32_t block_size, uint32_t header_off, int hash_size);
5050

5151
/* returns the block type (eg. 'r' for ref records. */

0 commit comments

Comments
 (0)