| 168 | } |
| 169 | |
| 170 | struct object_entry *packlist_alloc(struct packing_data *pdata, |
| 171 | const struct object_id *oid) |
| 172 | { |
| 173 | struct object_entry *new_entry; |
| 174 | |
| 175 | if (pdata->nr_objects >= pdata->nr_alloc) { |
| 176 | pdata->nr_alloc = (pdata->nr_alloc + 1024) * 3 / 2; |
| 177 | REALLOC_ARRAY(pdata->objects, pdata->nr_alloc); |
| 178 | |
| 179 | if (!pdata->in_pack_by_idx) |
| 180 | REALLOC_ARRAY(pdata->in_pack, pdata->nr_alloc); |
| 181 | if (pdata->delta_size) |
| 182 | REALLOC_ARRAY(pdata->delta_size, pdata->nr_alloc); |
| 183 | |
| 184 | if (pdata->tree_depth) |
| 185 | REALLOC_ARRAY(pdata->tree_depth, pdata->nr_alloc); |
| 186 | |
| 187 | if (pdata->layer) |
| 188 | REALLOC_ARRAY(pdata->layer, pdata->nr_alloc); |
| 189 | |
| 190 | if (pdata->cruft_mtime) |
| 191 | REALLOC_ARRAY(pdata->cruft_mtime, pdata->nr_alloc); |
| 192 | } |
| 193 | |
| 194 | new_entry = pdata->objects + pdata->nr_objects++; |
| 195 | |
| 196 | memset(new_entry, 0, sizeof(*new_entry)); |
| 197 | oidcpy(&new_entry->idx.oid, oid); |
| 198 | |
| 199 | if (pdata->index_size * 3 <= pdata->nr_objects * 4) |
| 200 | rehash_objects(pdata); |
| 201 | else { |
| 202 | int found; |
| 203 | uint32_t pos = locate_object_entry_hash(pdata, |
| 204 | &new_entry->idx.oid, |
| 205 | &found); |
| 206 | if (found) |
| 207 | BUG("duplicate object inserted into hash"); |
| 208 | pdata->index[pos] = pdata->nr_objects; |
| 209 | } |
| 210 | |
| 211 | if (pdata->in_pack) |
| 212 | pdata->in_pack[pdata->nr_objects - 1] = NULL; |
| 213 | |
| 214 | if (pdata->tree_depth) |
| 215 | pdata->tree_depth[pdata->nr_objects - 1] = 0; |
| 216 | |
| 217 | if (pdata->layer) |
| 218 | pdata->layer[pdata->nr_objects - 1] = 0; |
| 219 | |
| 220 | if (pdata->cruft_mtime) |
| 221 | pdata->cruft_mtime[pdata->nr_objects - 1] = 0; |
| 222 | |
| 223 | return new_entry; |
| 224 | } |
| 225 | |
| 226 | void oe_set_delta_ext(struct packing_data *pdata, |
| 227 | struct object_entry *delta, |