Skip to content

Commit 2f4af77

Browse files
peffgitster
authored andcommitted
csum-file: introduce hashfile_total()
We will need this helper function in a following commit to give us total number of bytes fed to the hashfile so far. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8ebf529 commit 2f4af77

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

csum-file.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ void hashflush(struct hashfile *f);
4242
void crc32_begin(struct hashfile *);
4343
uint32_t crc32_end(struct hashfile *);
4444

45+
/*
46+
* Returns the total number of bytes fed to the hashfile so far (including ones
47+
* that have not been written out to the descriptor yet).
48+
*/
49+
static inline off_t hashfile_total(struct hashfile *f)
50+
{
51+
return f->total + f->offset;
52+
}
53+
4554
static inline void hashwrite_u8(struct hashfile *f, uint8_t data)
4655
{
4756
hashwrite(f, &data, sizeof(data));

0 commit comments

Comments
 (0)