> diff --git a/delta-islands.c b/delta-islands.c > new file mode 100644 > index 0000000000..448ddcbbe4 > --- /dev/null > +++ b/delta-islands.c > +static void deduplicate_islands(void) > +{ > + struct remote_island *island, *core = NULL, **list; > + unsigned int island_count, dst, src, ref, i = 0; > + > + island_count = kh_size(remote_islands); > + list = xmalloc(island_count * sizeof(struct remote_island *)); Please use ALLOC_ARRAY here. > + > + kh_foreach_value(remote_islands, island, { > + list[i++] = island; > + }); > + > + for (ref = 0; ref + 1 < island_count; ref++) { > + for (src = ref + 1, dst = src; src < island_count; src++) { > + if (list[ref]->hash == list[src]->hash) > + continue; > + > + if (src != dst) > + list[dst] = list[src]; > + > + dst++; > + } > + island_count = dst; > + } > + > + island_bitmap_size = (island_count / 32) + 1; > + core = get_core_island(); > + > + for (i = 0; i < island_count; ++i) { > + mark_remote_island_1(list[i], core && list[i]->hash == core->hash); > + } > + > + free(list); > +}