MCPcopy Create free account
hub / github.com/git/git / hashwrite

Function hashwrite

csum-file.c:113–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113void hashwrite(struct hashfile *f, const void *buf, uint32_t count)
114{
115 while (count) {
116 unsigned left = f->buffer_len - f->offset;
117 unsigned nr = count > left ? left : count;
118
119 if (f->do_crc)
120 f->crc32 = crc32(f->crc32, buf, nr);
121
122 if (nr == f->buffer_len) {
123 /*
124 * Flush a full batch worth of data directly
125 * from the input, skipping the memcpy() to
126 * the hashfile's buffer. In this block,
127 * f->offset is necessarily zero.
128 */
129 if (!f->skip_hash)
130 git_hash_update(&f->ctx, buf, nr);
131 flush(f, buf, nr);
132 } else {
133 /*
134 * Copy to the hashfile's buffer, flushing only
135 * if it became full.
136 */
137 memcpy(f->buffer + f->offset, buf, nr);
138 f->offset += nr;
139 left -= nr;
140 if (!left)
141 hashflush(f);
142 }
143
144 count -= nr;
145 buf = (char *) buf + nr;
146 }
147}
148
149struct hashfile *hashfd_check(const struct git_hash_algo *algop,
150 const char *name)

Callers 15

hashwrite_u8Function · 0.85
hashwrite_be32Function · 0.85
hashwrite_be64Function · 0.85
stream_blob_to_packFunction · 0.85
write_graph_chunk_oidsFunction · 0.85
write_graph_chunk_dataFunction · 0.85
write_graph_chunk_base_1Function · 0.85
write_midx_pack_namesFunction · 0.85
write_midx_oid_lookupFunction · 0.85
write_idx_fileFunction · 0.85
write_rev_trailerFunction · 0.85

Calls 3

git_hash_updateFunction · 0.85
hashflushFunction · 0.85
flushFunction · 0.70

Tested by 1

write_ref_deltaFunction · 0.68