Re: [PATCH] tree-diff: avoid alloca for large allocations

2016-06-07 Thread Jeff King
On Tue, Jun 07, 2016 at 05:36:59PM -0700, Junio C Hamano wrote: > Jeff King writes: > > > An alternative to this would be implement something like: > > > > struct tree *tp, tp_fallback[2]; > > if (nparent <= ARRAY_SIZE(tp_fallback)) > > tp = tp_fallback; > > else > > ALLOC_

Re: [PATCH] tree-diff: avoid alloca for large allocations

2016-06-07 Thread Junio C Hamano
Jeff King writes: > An alternative to this would be implement something like: > > struct tree *tp, tp_fallback[2]; > if (nparent <= ARRAY_SIZE(tp_fallback)) > tp = tp_fallback; > else > ALLOC_ARRAY(tp, nparent); > ... > if (tp != tp_fallback) > free(tp); > > Th

[PATCH] tree-diff: avoid alloca for large allocations

2016-06-07 Thread Jeff King
Commit 72441af (tree-diff: rework diff_tree() to generate diffs for multiparent cases as well, 2014-04-07) introduced the use of alloca so that the common cases of commits with 1 or 2 parents would not be adversely affected by going through the multi-parent code. However, our xalloca is not ideal