{"thread":{"id":"7437","subject":"[PATCH] use xrealloc in help.c","startedAt":"2007-03-27T22:30:08Z","lastAt":"2007-03-28T00:53:52Z","messageCount":3,"participants":["James Bowes","Morten Welinder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"38192","messageId":"1175034608589-git-send-email-jbowes@dangerouslyinc.com","threadId":"7437","inReplyTo":null,"subject":"[PATCH] use xrealloc in help.c","fromName":"James Bowes","fromEmail":"jbowes@dangerouslyinc.com","sentAt":"2007-03-27T22:30:08Z","receivedAt":"2007-03-27T22:30:08Z","isPatch":true,"sender":{"key":"jbowes@dangerouslyinc.com","avatar":"https://gravatar.com/avatar/a2fe98c66b2b47a9fa9d2ba92ff949d54c3208b1f8acc2e745b4b84ae3c4483a?d=mp&s=160"},"body":"Signed-off-by: James Bowes <jbowes@dangerouslyinc.com>\n---\n help.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/help.c b/help.c\nindex be8651a..34b1dda 100644\n--- a/help.c\n+++ b/help.c\n@@ -54,7 +54,7 @@ static void add_cmdname(const char *name, int len)\n \tstruct cmdname *ent;\n \tif (cmdname_alloc <= cmdname_cnt) {\n \t\tcmdname_alloc = cmdname_alloc + 200;\n-\t\tcmdname = realloc(cmdname, cmdname_alloc * sizeof(*cmdname));\n+\t\tcmdname = xrealloc(cmdname, cmdname_alloc * sizeof(*cmdname));\n \t\tif (!cmdname)\n \t\t\toom();\n \t}\n-- \n1.5.0.5\n"},{"id":"38194","messageId":"118833cc0703271540l6615b413gd1df3dc5525a2d00@mail.gmail.com","threadId":"7437","inReplyTo":"1175034608589-git-send-email-jbowes@dangerouslyinc.com","subject":"Re: [PATCH] use xrealloc in help.c","fromName":"Morten Welinder","fromEmail":"mwelinder@gmail.com","sentAt":"2007-03-27T22:40:45Z","receivedAt":"2007-03-27T22:40:45Z","isPatch":true,"sender":{"key":"mwelinder@gmail.com","avatar":null},"body":"> -               cmdname = realloc(cmdname, cmdname_alloc * sizeof(*cmdname));\n> +               cmdname = xrealloc(cmdname, cmdname_alloc * sizeof(*cmdname));\n>                 if (!cmdname)\n>                         oom();\n\nIf you are using xrealloc, shouldn't kill the oom check here too?\n\nM.\n"},{"id":"38215","messageId":"3f80363f0703271753h631f52f4v3899b877285962@mail.gmail.com","threadId":"7437","inReplyTo":"118833cc0703271540l6615b413gd1df3dc5525a2d00@mail.gmail.com","subject":"Re: [PATCH] use xrealloc in help.c","fromName":"James Bowes","fromEmail":"jbowes@dangerouslyinc.com","sentAt":"2007-03-28T00:53:52Z","receivedAt":"2007-03-28T00:53:52Z","isPatch":true,"sender":{"key":"jbowes@dangerouslyinc.com","avatar":"https://gravatar.com/avatar/a2fe98c66b2b47a9fa9d2ba92ff949d54c3208b1f8acc2e745b4b84ae3c4483a?d=mp&s=160"},"body":"oom() is not needed any more either, since the x* functions check the return\nthemselves. So get rid of it.\n\nSigned-off-by: James Bowes <jbowes@dangerouslyinc.com>\n---\n\nOn 3/27/07, Morten Welinder <mwelinder@gmail.com> wrote:\n> If you are using xrealloc, shouldn't kill the oom check here too?\n\nGood point. There's no need for oom() at all then, anymore.\n\n help.c |   12 +-----------\n 1 files changed, 1 insertions(+), 11 deletions(-)\n\ndiff --git a/help.c b/help.c\nindex be8651a..6a9af4d 100644\n--- a/help.c\n+++ b/help.c\n@@ -31,12 +31,6 @@ static int term_columns(void)\n \treturn 80;\n }\n\n-static void oom(void)\n-{\n-\tfprintf(stderr, \"git: out of memory\\n\");\n-\texit(1);\n-}\n-\n static inline void mput_char(char c, unsigned int num)\n {\n \twhile(num--)\n@@ -54,13 +48,9 @@ static void add_cmdname(const char *name, int len)\n \tstruct cmdname *ent;\n \tif (cmdname_alloc <= cmdname_cnt) {\n \t\tcmdname_alloc = cmdname_alloc + 200;\n-\t\tcmdname = realloc(cmdname, cmdname_alloc * sizeof(*cmdname));\n-\t\tif (!cmdname)\n-\t\t\toom();\n+\t\tcmdname = xrealloc(cmdname, cmdname_alloc * sizeof(*cmdname));\n \t}\n \tent = xmalloc(sizeof(*ent) + len);\n-\tif (!ent)\n-\t\toom();\n \tent->len = len;\n \tmemcpy(ent->name, name, len);\n \tent->name[len] = 0;\n-- \n1.5.0.5\n"}]}