| 256 | } |
| 257 | |
| 258 | static 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 | |
| 292 | out: |
| 293 | free(data); |
| 294 | return ret; |
| 295 | } |
| 296 | |
| 297 | static int odb_source_inmemory_freshen_object(struct odb_source *source, |
| 298 | const struct object_id *oid) |
nothing calls this directly
no test coverage detected