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

Re: [PATCH] builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Dec 19, 2010, 03:02 UTC
Message-ID
<AANLkTim4GE0mnCBqz6QubpL6g9Bz5U-jHoOw=_MR5-1j@mail.gmail.com>
In-Reply-To
<ffd7b63f3ef5e409775a0d730691efdaf4e41592.1292291262.git.tfransosi@gmail.com>
On Tue, Dec 14, 2010 at 8:48 AM, Thiago Farina <tfransosi@gmail.com> wrote:
Show 9 quoted lines
>  static void add_list(const char *name)
>  {
> -       if (list.nr >= list.alloc) {
> -               list.alloc = alloc_nr(list.alloc);
> -               list.name = xrealloc(list.name, list.alloc * sizeof(const char *));
> -       }
> +       ALLOC_GROW(list.name, list.nr + 1, list.alloc);
>        list.name[list.nr++] = name;
>  }

add_list() is only used at one place, why not remove it and put the code back in cmd_rm()?

-- 
Duy
Previous: Thiago FarinaNext: Thiago Farina
Message 3 of 5 in “builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.”
  1. builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.Thiago Farina, Dec 14, 2010
  2. Thiago FarinaDec 18, 2010
  3. Nguyen Thai Ngoc DuyDec 19, 2010
  4. builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.Thiago Farina, Dec 19, 2010
  5. Thiago FarinaDec 19, 2010

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.