Skip to content

Commit dcda361

Browse files
committed
builtin-pack-objects.c: avoid vla
This is one of only two places that we use C99 variable length array on the stack, which some older compilers apparently are not happy with. Signed-off-by: Junio C Hamano <[email protected]>
1 parent eeefa7c commit dcda361

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin-pack-objects.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ static void *threaded_find_deltas(void *arg)
15991599
static void ll_find_deltas(struct object_entry **list, unsigned list_size,
16001600
int window, int depth, unsigned *processed)
16011601
{
1602-
struct thread_params p[delta_search_threads];
1602+
struct thread_params *p;
16031603
int i, ret, active_threads = 0;
16041604

16051605
if (delta_search_threads <= 1) {
@@ -1609,6 +1609,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
16091609
if (progress > pack_to_stdout)
16101610
fprintf(stderr, "Delta compression using up to %d threads.\n",
16111611
delta_search_threads);
1612+
p = xcalloc(delta_search_threads, sizeof(*p));
16121613

16131614
/* Partition the work amongst work threads. */
16141615
for (i = 0; i < delta_search_threads; i++) {
@@ -1717,6 +1718,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
17171718
active_threads--;
17181719
}
17191720
}
1721+
free(p);
17201722
}
17211723

17221724
#else

0 commit comments

Comments
 (0)