| 442 | } |
| 443 | |
| 444 | void add_object_array_with_path(struct object *obj, const char *name, |
| 445 | struct object_array *array, |
| 446 | unsigned mode, const char *path) |
| 447 | { |
| 448 | unsigned nr = array->nr; |
| 449 | unsigned alloc = array->alloc; |
| 450 | struct object_array_entry *objects = array->objects; |
| 451 | struct object_array_entry *entry; |
| 452 | |
| 453 | if (nr >= alloc) { |
| 454 | alloc = (alloc + 32) * 2; |
| 455 | REALLOC_ARRAY(objects, alloc); |
| 456 | array->alloc = alloc; |
| 457 | array->objects = objects; |
| 458 | } |
| 459 | entry = &objects[nr]; |
| 460 | entry->item = obj; |
| 461 | if (!name) |
| 462 | entry->name = NULL; |
| 463 | else if (!*name) |
| 464 | /* Use our own empty string instead of allocating one: */ |
| 465 | entry->name = object_array_slopbuf; |
| 466 | else |
| 467 | entry->name = xstrdup(name); |
| 468 | entry->mode = mode; |
| 469 | if (path) |
| 470 | entry->path = xstrdup(path); |
| 471 | else |
| 472 | entry->path = NULL; |
| 473 | array->nr = ++nr; |
| 474 | } |
| 475 | |
| 476 | void add_object_array(struct object *obj, const char *name, struct object_array *array) |
| 477 | { |
no test coverage detected