Jeff King <peff@xxxxxxxx> writes: > But back in the caller... > >> p = m->packs[pack_int_id - m->num_packs_in_base]; >> ... > > Our pack_int_id is the global one, so it needs to be adjusted. But this > pack pointer we access is the same one that was filled (or not) by > prepare_midx_pack(). So it cannot be NULL or the magic "fails" value, > because prepare_midx_pack() returned 0. > > So I think this code is fine. Ahh, I missed that call to midx_for_pack() in prepare_midx_pack() that modifies pack_int_id variable. Of course, it did not help that the implementation detail of adjusting by m->num_packs_in_base which is done in midx_for_pack() is not abstracted out and the caller needs to do the same as above. That confused me. Thanks for an explanation.