git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [GSoC][RFC][PATCH 2/2] STRBUF_INIT_CONST: Adapting strbuf_* functions

From
Robear Selwans <rwagih.rw@gmail.com>
Date
Feb 19, 2020, 04:34 UTC
Message-ID
<CALH1-XoXdpAxYj7r1ouc-v4KrVuYDocBFFC++7eFiRwdHFxmUA@mail.gmail.com>
In-Reply-To
<xmqqv9o3gthb.fsf@gitster-ct.c.googlers.com>
On Wed, Feb 19, 2020 at 5:13 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 16 quoted lines
>
> Yes, but the case that matters to _your_ use is sb->alloc == 0.  You
> do not want to let a broken strbuf (presumably broken by changes
> other than your own) to pass, when you can detect it.  And for that,
> paying attention to sb->len _might_ make sense, but then the check
> won't be
>
>         if (sb->alloc < sb->len)
>                 make it mutable;
>
> you'd rather be writing something like
>
>         if (!sb->alloc)
>                 make it mutable;
>         else if (sb->alloc < sb->len)
>                 BUG("somebody fed a corrupt strbuf to me");

Ooh so what you meant, is that corrupt `strbuf`s need to be anticipated even if they don't make much sense. Smart.

Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 8 in “Re: [GSoC][RFC][PATCH 2/2] STRBUF_INIT_CONST: Adapting strbuf_* functions”
  1. Abhishek KumarFeb 18, 2020
  2. Robear SelwansFeb 18, 2020
  3. Junio C HamanoFeb 18, 2020
  4. Robear SelwansFeb 19, 2020
  5. Jeff KingFeb 19, 2020
  6. Junio C HamanoFeb 19, 2020
  7. Robear SelwansFeb 19, 2020
  8. Junio C HamanoFeb 19, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.