| 227 | } |
| 228 | |
| 229 | static int odb_source_inmemory_write_object(struct odb_source *source, |
| 230 | const void *buf, unsigned long len, |
| 231 | enum object_type type, |
| 232 | struct object_id *oid, |
| 233 | struct object_id *compat_oid UNUSED, |
| 234 | enum odb_write_object_flags flags UNUSED) |
| 235 | { |
| 236 | struct odb_source_inmemory *inmemory = odb_source_inmemory_downcast(source); |
| 237 | struct inmemory_object *object; |
| 238 | |
| 239 | hash_object_file(source->odb->repo->hash_algo, buf, len, type, oid); |
| 240 | |
| 241 | if (!inmemory->objects) { |
| 242 | CALLOC_ARRAY(inmemory->objects, 1); |
| 243 | oidtree_init(inmemory->objects); |
| 244 | } else if (oidtree_contains(inmemory->objects, oid)) { |
| 245 | return 0; |
| 246 | } |
| 247 | |
| 248 | CALLOC_ARRAY(object, 1); |
| 249 | object->size = len; |
| 250 | object->type = type; |
| 251 | object->buf = xmemdupz(buf, len); |
| 252 | |
| 253 | oidtree_insert(inmemory->objects, oid, object); |
| 254 | |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | static int odb_source_inmemory_write_object_stream(struct odb_source *source, |
| 259 | struct odb_write_stream *stream, |
no test coverage detected