{"thread":{"id":"26046","subject":"[PATCH] builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.","startedAt":"2010-12-14T01:48:10Z","lastAt":"2010-12-19T11:58:19Z","messageCount":5,"participants":["Thiago Farina","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"158014","messageId":"ffd7b63f3ef5e409775a0d730691efdaf4e41592.1292291262.git.tfransosi@gmail.com","threadId":"26046","inReplyTo":null,"subject":"[PATCH] builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2010-12-14T01:48:10Z","receivedAt":"2010-12-14T01:48:10Z","isPatch":true,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"Signed-off-by: Thiago Farina <tfransosi@gmail.com>\n---\n builtin/rm.c |    5 +----\n 1 files changed, 1 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex c7b7bb3..faeedfc 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -22,10 +22,7 @@ static struct {\n \n static void add_list(const char *name)\n {\n-\tif (list.nr >= list.alloc) {\n-\t\tlist.alloc = alloc_nr(list.alloc);\n-\t\tlist.name = xrealloc(list.name, list.alloc * sizeof(const char *));\n-\t}\n+\tALLOC_GROW(list.name, list.nr + 1, list.alloc);\n \tlist.name[list.nr++] = name;\n }\n \n-- \n1.7.3.2.343.g7d43d\n"},{"id":"158347","messageId":"AANLkTimLy0uE980GFfaVJt19XuhZDO2OLRbEgs=oyY=2@mail.gmail.com","threadId":"26046","inReplyTo":"ffd7b63f3ef5e409775a0d730691efdaf4e41592.1292291262.git.tfransosi@gmail.com","subject":"Re: [PATCH] builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2010-12-18T23:03:05Z","receivedAt":"2010-12-18T23:03:05Z","isPatch":true,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"On Mon, Dec 13, 2010 at 11:48 PM, Thiago Farina <tfransosi@gmail.com> wrote:\n> Signed-off-by: Thiago Farina <tfransosi@gmail.com>\n> ---\n>  builtin/rm.c |    5 +----\n>  1 files changed, 1 insertions(+), 4 deletions(-)\n>\n> diff --git a/builtin/rm.c b/builtin/rm.c\n> index c7b7bb3..faeedfc 100644\n> --- a/builtin/rm.c\n> +++ b/builtin/rm.c\n> @@ -22,10 +22,7 @@ static struct {\n>\n>  static void add_list(const char *name)\n>  {\n> -       if (list.nr >= list.alloc) {\n> -               list.alloc = alloc_nr(list.alloc);\n> -               list.name = xrealloc(list.name, list.alloc * sizeof(const char *));\n> -       }\n> +       ALLOC_GROW(list.name, list.nr + 1, list.alloc);\n>        list.name[list.nr++] = name;\n>  }\n>\n\n+Jonathan, he might Ack this.\n"},{"id":"158351","messageId":"AANLkTim4GE0mnCBqz6QubpL6g9Bz5U-jHoOw=_MR5-1j@mail.gmail.com","threadId":"26046","inReplyTo":"ffd7b63f3ef5e409775a0d730691efdaf4e41592.1292291262.git.tfransosi@gmail.com","subject":"Re: [PATCH] builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-12-19T03:02:39Z","receivedAt":"2010-12-19T03:02:39Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Dec 14, 2010 at 8:48 AM, Thiago Farina <tfransosi@gmail.com> wrote:\n>  static void add_list(const char *name)\n>  {\n> -       if (list.nr >= list.alloc) {\n> -               list.alloc = alloc_nr(list.alloc);\n> -               list.name = xrealloc(list.name, list.alloc * sizeof(const char *));\n> -       }\n> +       ALLOC_GROW(list.name, list.nr + 1, list.alloc);\n>        list.name[list.nr++] = name;\n>  }\n\nadd_list() is only used at one place, why not remove it and put the\ncode back in cmd_rm()?\n-- \nDuy\n"},{"id":"158357","messageId":"97af5e0255d234e3a7ec5df1e387bec39ed94206.1292759580.git.tfransosi@gmail.com","threadId":"26046","inReplyTo":"AANLkTim4GE0mnCBqz6QubpL6g9Bz5U-jHoOw=_MR5-1j@mail.gmail.com","subject":"[PATCH v2] builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2010-12-19T11:56:25Z","receivedAt":"2010-12-19T11:56:25Z","isPatch":true,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"Signed-off-by: Thiago Farina <tfransosi@gmail.com>\n---\n Changes from v1:\n - Remove the add_list function since it's used only once per Nguyen Thai Ngoc Duy\n   review.\n\n builtin/rm.c |   12 ++----------\n 1 files changed, 2 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex c7b7bb3..ff491d7 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -20,15 +20,6 @@ static struct {\n \tconst char **name;\n } list;\n \n-static void add_list(const char *name)\n-{\n-\tif (list.nr >= list.alloc) {\n-\t\tlist.alloc = alloc_nr(list.alloc);\n-\t\tlist.name = xrealloc(list.name, list.alloc * sizeof(const char *));\n-\t}\n-\tlist.name[list.nr++] = name;\n-}\n-\n static int check_local_mod(unsigned char *head, int index_only)\n {\n \t/*\n@@ -182,7 +173,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \t\tstruct cache_entry *ce = active_cache[i];\n \t\tif (!match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen))\n \t\t\tcontinue;\n-\t\tadd_list(ce->name);\n+\t\tALLOC_GROW(list.name, list.nr + 1, list.alloc);\n+\t\tlist.name[list.nr++] = ce->name;\n \t}\n \n \tif (pathspec) {\n-- \n1.7.3.2.343.g7d43d\n"},{"id":"158358","messageId":"AANLkTim-zv6WZZ_DErnoNBhgJw3DnC0jHSH-Mg2CzkhV@mail.gmail.com","threadId":"26046","inReplyTo":"97af5e0255d234e3a7ec5df1e387bec39ed94206.1292759580.git.tfransosi@gmail.com","subject":"Re: [PATCH v2] builtin/rm.c: Use ALLOC_GROW instead of alloc_nr and xrealloc.","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2010-12-19T11:58:19Z","receivedAt":"2010-12-19T11:58:19Z","isPatch":true,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"Forgot to copy Jonathan when using 'git send-email'. Now copying him.\n\nOn Sun, Dec 19, 2010 at 9:56 AM, Thiago Farina <tfransosi@gmail.com> wrote:\n> Signed-off-by: Thiago Farina <tfransosi@gmail.com>\n> ---\n>  Changes from v1:\n>  - Remove the add_list function since it's used only once per Nguyen Thai Ngoc Duy\n>   review.\n>\n>  builtin/rm.c |   12 ++----------\n>  1 files changed, 2 insertions(+), 10 deletions(-)\n>\n> diff --git a/builtin/rm.c b/builtin/rm.c\n> index c7b7bb3..ff491d7 100644\n> --- a/builtin/rm.c\n> +++ b/builtin/rm.c\n> @@ -20,15 +20,6 @@ static struct {\n>        const char **name;\n>  } list;\n>\n> -static void add_list(const char *name)\n> -{\n> -       if (list.nr >= list.alloc) {\n> -               list.alloc = alloc_nr(list.alloc);\n> -               list.name = xrealloc(list.name, list.alloc * sizeof(const char *));\n> -       }\n> -       list.name[list.nr++] = name;\n> -}\n> -\n>  static int check_local_mod(unsigned char *head, int index_only)\n>  {\n>        /*\n> @@ -182,7 +173,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n>                struct cache_entry *ce = active_cache[i];\n>                if (!match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen))\n>                        continue;\n> -               add_list(ce->name);\n> +               ALLOC_GROW(list.name, list.nr + 1, list.alloc);\n> +               list.name[list.nr++] = ce->name;\n>        }\n>\n>        if (pathspec) {\n> --\n> 1.7.3.2.343.g7d43d\n>\n>\n"}]}