From: Junio C Hamano Date: Fri, 29 Aug 2025 16:33:55 GMT Subject: Re: [PATCH v3] range-diff: add configurable memory limit for cost matrix Message-ID: In-Reply-To: Elijah Newren writes: > On Fri, Aug 29, 2025 at 4:00 AM Paulo Casaretto via GitGitGadget > wrote: >> - >> - ALLOC_ARRAY(cost, st_mult(n, n)); >> + size_t cost_size = st_mult(n, n); >> + size_t cost_bytes = st_mult(sizeof(int), cost_size); >> + if (cost_bytes >= max_memory) { >> + struct strbuf cost_str = STRBUF_INIT; >> + struct strbuf max_str = STRBUF_INIT; >> + strbuf_humanise_bytes(&cost_str, cost_bytes); >> + strbuf_humanise_bytes(&max_str, max_memory); >> + die(_("range-diff: unable to compute the range-diff, since it " >> + "exceeds the maximum memory for the cost matrix: %s " >> + "(%"PRIuMAX" bytes) needed, %s (%"PRIuMAX" bytes) available"), >> + cost_str.buf, (uintmax_t)cost_bytes, max_str.buf, (uintmax_t)max_memory); >> + } >> + ALLOC_ARRAY(cost, cost_size); >> ALLOC_ARRAY(a2b, n); >> ALLOC_ARRAY(b2a, n); >> > > This still has the same wording issue that I commented on in v2: > https://lore.kernel.org/git/CABPp-BEDje5dYZHEyYMN6j_LdR5CqRN1cxc0riRK06qK-OxiTA@mail.gmail.com/ Right. I overlooked it, sorry.