MCPcopy Index your code
hub / github.com/git/git / odb_source_inmemory_write_object_stream

Function odb_source_inmemory_write_object_stream

odb/source-inmemory.c:258–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258static int odb_source_inmemory_write_object_stream(struct odb_source *source,
259 struct odb_write_stream *stream,
260 size_t len,
261 struct object_id *oid)
262{
263 char buf[16384];
264 size_t total_read = 0;
265 char *data;
266 int ret;
267
268 CALLOC_ARRAY(data, len);
269 while (!stream->is_finished) {
270 ssize_t bytes_read;
271
272 bytes_read = odb_write_stream_read(stream, buf, sizeof(buf));
273 if (total_read + bytes_read > len) {
274 ret = error("object stream yielded more bytes than expected");
275 goto out;
276 }
277
278 memcpy(data + total_read, buf, bytes_read);
279 total_read += bytes_read;
280 }
281
282 if (total_read != len) {
283 ret = error("object stream yielded less bytes than expected");
284 goto out;
285 }
286
287 ret = odb_source_inmemory_write_object(source, data, len, OBJ_BLOB, oid,
288 NULL, 0);
289 if (ret < 0)
290 goto out;
291
292out:
293 free(data);
294 return ret;
295}
296
297static int odb_source_inmemory_freshen_object(struct odb_source *source,
298 const struct object_id *oid)

Callers

nothing calls this directly

Calls 3

odb_write_stream_readFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected