commit 367c26efe780933f7fc2201384d8e1c0feb8a77a
parent b9b80b4a398fded00a036a37a98d257940eb04d2
Author: sin <sin@2f30.org>
Date: Sat, 31 Mar 2018 10:04:14 +0100
Rename sz to size
Diffstat:
M | dedup.c | | | 32 | ++++++++++++++++---------------- |
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/dedup.c b/dedup.c
@@ -23,7 +23,7 @@ struct enthdr {
} __attribute__((packed));
struct ent {
- uint64_t sz; /* size of entire entry structure */
+ uint64_t size;
uint8_t reserved[7];
uint8_t md[32];
uint64_t nblks;
@@ -32,7 +32,7 @@ struct ent {
struct blk {
uint8_t md[32];
- uint64_t sz;
+ uint64_t size;
uint8_t data[BLKSIZ];
} __attribute__((packed));
@@ -78,7 +78,7 @@ dump_ent(struct ent *ent)
{
uint64_t i;
- fprintf(stderr, "ent->sz: %llu\n", (unsigned long long)ent->sz);
+ fprintf(stderr, "ent->size: %llu\n", (unsigned long long)ent->size);
fprintf(stderr, "ent->md: ");
dump_md(ent->md, sizeof(ent->md));
fputc('\n', stderr);
@@ -98,7 +98,7 @@ dump_blk(struct blk *blk)
fprintf(stderr, "blk->md: ");
dump_md(blk->md, sizeof(blk->md));
putchar('\n');
- fprintf(stderr, "blk->sz: %llu\n", (unsigned long long)blk->sz);
+ fprintf(stderr, "blk->size: %llu\n", (unsigned long long)blk->size);
}
void
@@ -219,9 +219,9 @@ append_ent(struct ent *ent)
/* Append entry */
lseek(ifd, 0, SEEK_END);
- ent->sz = sizeof(*ent);
- ent->sz += ent->nblks * sizeof(ent->blks[0]);
- xwrite(ifd, ent, ent->sz);
+ ent->size = sizeof(*ent);
+ ent->size += ent->nblks * sizeof(ent->blks[0]);
+ xwrite(ifd, ent, ent->size);
}
struct ent *
@@ -238,11 +238,11 @@ alloc_ent(void)
struct ent *
grow_ent(struct ent *ent, uint64_t nblks)
{
- size_t sz;
+ size_t size;
- sz = sizeof(*ent);
- sz += nblks * sizeof(ent->blks[0]);
- ent = realloc(ent, sz);
+ size = sizeof(*ent);
+ size += nblks * sizeof(ent->blks[0]);
+ ent = realloc(ent, size);
if (ent == NULL)
err(1, "realloc");
return ent;
@@ -274,7 +274,7 @@ hash_blk(struct blk *blk)
sha256_context ctx;
sha256_starts(&ctx);
- sha256_update(&ctx, blk->data, blk->sz);
+ sha256_update(&ctx, blk->data, blk->size);
sha256_finish(&ctx, blk->md);
}
@@ -346,7 +346,7 @@ extract(char *id, int fd)
if (ent->blks[j] > nblks)
errx(1, "index is corrupted");
read_blk(&blk, ent->blks[j]);
- xwrite(fd, blk.data, blk.sz);
+ xwrite(fd, blk.data, blk.size);
}
free(ent);
break;
@@ -368,11 +368,11 @@ dedup(int fd)
while ((n = xread(fd, blk.data, BLKSIZ)) > 0) {
uint64_t blkidx;
- blk.sz = n;
+ blk.size = n;
hash_blk(&blk);
/* Rolling hash of input stream */
- sha256_update(&ctx, blk.data, blk.sz);
+ sha256_update(&ctx, blk.data, blk.size);
/* Prepare for adding a new block index for this entry */
ent = grow_ent(ent, ent->nblks + 1);
@@ -430,7 +430,7 @@ check(void)
if (ent->blks[j] > nblks)
errx(1, "index is corrupted");
read_blk(&blk, ent->blks[j]);
- sha256_update(&ctx, blk.data, blk.sz);
+ sha256_update(&ctx, blk.data, blk.size);
}
sha256_finish(&ctx, md);