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

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

From
Thiago Farina <tfransosi@gmail.com>
Date
Dec 19, 2010, 11:58 UTC
Message-ID
<AANLkTim-zv6WZZ_DErnoNBhgJw3DnC0jHSH-Mg2CzkhV@mail.gmail.com>
In-Reply-To
<97af5e0255d234e3a7ec5df1e387bec39ed94206.1292759580.git.tfransosi@gmail.com>
Forgot to copy Jonathan when using 'git send-email'. Now copying him.
On Sun, Dec 19, 2010 at 9:56 AM, Thiago Farina <tfransosi@gmail.com> wrote:
Show 43 quoted lines
> Signed-off-by: Thiago Farina <tfransosi@gmail.com>
> ---
>  Changes from v1:
>  - Remove the add_list function since it's used only once per Nguyen Thai Ngoc Duy
>   review.
>
>  builtin/rm.c |   12 ++----------
>  1 files changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/builtin/rm.c b/builtin/rm.c
> index c7b7bb3..ff491d7 100644
> --- a/builtin/rm.c
> +++ b/builtin/rm.c
> @@ -20,15 +20,6 @@ static struct {
>        const char **name;
>  } list;
>
> -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 *));
> -       }
> -       list.name[list.nr++] = name;
> -}
> -
>  static int check_local_mod(unsigned char *head, int index_only)
>  {
>        /*
> @@ -182,7 +173,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
>                struct cache_entry *ce = active_cache[i];
>                if (!match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen))
>                        continue;
> -               add_list(ce->name);
> +               ALLOC_GROW(list.name, list.nr + 1, list.alloc);
> +               list.name[list.nr++] = ce->name;
>        }
>
>        if (pathspec) {
> --
> 1.7.3.2.343.g7d43d
>
>
Previous: Thiago Farina
Message 5 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.