if (offset) {
if (!f->skip_hash)
- f->algop->unsafe_update_fn(&f->ctx, f->buffer, offset);
+ f->algop->update_fn(&f->ctx, f->buffer, offset);
flush(f, f->buffer, offset);
f->offset = 0;
}
if (f->skip_hash)
hashclr(f->buffer, f->algop);
else
- f->algop->unsafe_final_fn(f->buffer, &f->ctx);
+ f->algop->final_fn(f->buffer, &f->ctx);
if (result)
hashcpy(result, f->buffer, f->algop);
* f->offset is necessarily zero.
*/
if (!f->skip_hash)
- f->algop->unsafe_update_fn(&f->ctx, buf, nr);
+ f->algop->update_fn(&f->ctx, buf, nr);
flush(f, buf, nr);
} else {
/*
f->do_crc = 0;
f->skip_hash = 0;
- f->algop = the_hash_algo;
- f->algop->unsafe_init_fn(&f->ctx);
+ f->algop = unsafe_hash_algo(the_hash_algo);
+ f->algop->init_fn(&f->ctx);
f->buffer_len = buffer_len;
f->buffer = xmalloc(buffer_len);
{
hashflush(f);
checkpoint->offset = f->total;
- f->algop->unsafe_clone_fn(&checkpoint->ctx, &f->ctx);
+ f->algop->clone_fn(&checkpoint->ctx, &f->ctx);
}
int hashfile_truncate(struct hashfile *f, struct hashfile_checkpoint *checkpoint)
lseek(f->fd, offset, SEEK_SET) != offset)
return -1;
f->total = offset;
- f->algop->unsafe_clone_fn(&f->ctx, &checkpoint->ctx);
+ f->algop->clone_fn(&f->ctx, &checkpoint->ctx);
f->offset = 0; /* hashflush() was called in checkpoint */
return 0;
}
{
unsigned char got[GIT_MAX_RAWSZ];
git_hash_ctx ctx;
- const struct git_hash_algo *algop = the_hash_algo;
+ const struct git_hash_algo *algop = unsafe_hash_algo(the_hash_algo);
size_t data_len = total_len - algop->rawsz;
if (total_len < algop->rawsz)
return 0; /* say "too short"? */
- algop->unsafe_init_fn(&ctx);
- algop->unsafe_update_fn(&ctx, data, data_len);
- algop->unsafe_final_fn(got, &ctx);
+ algop->init_fn(&ctx);
+ algop->update_fn(&ctx, data, data_len);
+ algop->final_fn(got, &ctx);
return hasheq(got, data + data_len, algop);
}