Re: [PATCH v3 2/6] pack-bitmap-write.c: write lookup table extension
- From
- Martin Ågren <martin.agren@gmail.com>
- Date
- Jul 18, 2022, 08:59 UTC
- Message-ID
- <CAN0heSoBca4BcBgR01cwE567NHQyjO+gRkY1V_6Z0nEd-_tW4g@mail.gmail.com>
- In-Reply-To
- <5e9b985e39b0b9edee7af55dd8b0698a20062cf7.1656924376.git.gitgitgadget@gmail.com>
On Mon, 4 Jul 2022 at 10:48, Abhradeep Chakraborty via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 6 quoted lines
>
> +static int table_cmp(const void *_va, const void *_vb, void *_data)
> +{
> + uint32_t *commit_positions = _data;
> + uint32_t a = commit_positions[*(uint32_t *)_va];
> + uint32_t b = commit_positions[*(uint32_t *)_vb];This casting and dereferencing are ok because ...
Show 11 quoted lines
> +static void write_lookup_table(struct hashfile *f,
> + struct pack_idx_entry **index,
> + uint32_t index_nr,
> + off_t *offsets)
> +{
> + uint32_t i;
> + uint32_t *table, *table_inv, *commit_positions;
> +
> + ALLOC_ARRAY(table, writer.selected_nr);
> + ALLOC_ARRAY(table_inv, writer.selected_nr);
> + ALLOC_ARRAY(commit_positions, writer.selected_nr);... `table` is where `_va` and `_vb` will be pointing into.
> + QSORT_S(table, writer.selected_nr, table_cmp, commit_positions);
I started looking at this casting because of something similar in "pack-bitmap: prepare to read lookup table extension". I'm pointing out this instance just to say that it looks ok to me.
Martin