diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-02-10 10:18:30 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-02-10 10:18:31 -0800 |
| commit | 246569bf83f2a586268d26559c7d6ea54c9316b6 (patch) | |
| tree | 29bdf8fd459a337adef85012b88d6ed71830a147 /csum-file.c | |
| parent | 0ca6b46d7ca17988da3b7292097e5608be81abad (diff) | |
| parent | 0578f1e66aa381356bfe2f53decf3864d88d23d3 (diff) | |
Merge branch 'ps/hash-cleanup'
Further code clean-up on the use of hash functions. Now the
context object knows what hash function it is working with.
* ps/hash-cleanup:
global: adapt callers to use generic hash context helpers
hash: provide generic wrappers to update hash contexts
hash: stop typedeffing the hash context
hash: convert hashing context to a structure
Diffstat (limited to 'csum-file.c')
| -rw-r--r-- | csum-file.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/csum-file.c b/csum-file.c index c81645ba08..b58c183a4f 100644 --- a/csum-file.c +++ b/csum-file.c @@ -51,7 +51,7 @@ void hashflush(struct hashfile *f) if (offset) { if (!f->skip_hash) - f->algop->update_fn(&f->ctx, f->buffer, offset); + git_hash_update(&f->ctx, f->buffer, offset); flush(f, f->buffer, offset); f->offset = 0; } @@ -74,7 +74,7 @@ int finalize_hashfile(struct hashfile *f, unsigned char *result, if (f->skip_hash) hashclr(f->buffer, f->algop); else - f->algop->final_fn(f->buffer, &f->ctx); + git_hash_final(f->buffer, &f->ctx); if (result) hashcpy(result, f->buffer, f->algop); @@ -129,7 +129,7 @@ void hashwrite(struct hashfile *f, const void *buf, unsigned int count) * f->offset is necessarily zero. */ if (!f->skip_hash) - f->algop->update_fn(&f->ctx, buf, nr); + git_hash_update(&f->ctx, buf, nr); flush(f, buf, nr); } else { /* @@ -218,7 +218,7 @@ void hashfile_checkpoint(struct hashfile *f, struct hashfile_checkpoint *checkpo { hashflush(f); checkpoint->offset = f->total; - f->algop->clone_fn(&checkpoint->ctx, &f->ctx); + git_hash_clone(&checkpoint->ctx, &f->ctx); } int hashfile_truncate(struct hashfile *f, struct hashfile_checkpoint *checkpoint) @@ -229,7 +229,7 @@ int hashfile_truncate(struct hashfile *f, struct hashfile_checkpoint *checkpoint lseek(f->fd, offset, SEEK_SET) != offset) return -1; f->total = offset; - f->algop->clone_fn(&f->ctx, &checkpoint->ctx); + git_hash_clone(&f->ctx, &checkpoint->ctx); f->offset = 0; /* hashflush() was called in checkpoint */ return 0; } @@ -249,7 +249,7 @@ uint32_t crc32_end(struct hashfile *f) int hashfile_checksum_valid(const unsigned char *data, size_t total_len) { unsigned char got[GIT_MAX_RAWSZ]; - git_hash_ctx ctx; + struct git_hash_ctx ctx; const struct git_hash_algo *algop = unsafe_hash_algo(the_hash_algo); size_t data_len = total_len - algop->rawsz; @@ -257,8 +257,8 @@ int hashfile_checksum_valid(const unsigned char *data, size_t total_len) return 0; /* say "too short"? */ algop->init_fn(&ctx); - algop->update_fn(&ctx, data, data_len); - algop->final_fn(got, &ctx); + git_hash_update(&ctx, data, data_len); + git_hash_final(got, &ctx); return hasheq(got, data + data_len, algop); } |
