Skip to content

Commit

Permalink
use xrealloc in help.c
Browse files Browse the repository at this point in the history
Signed-off-by: James Bowes <jbowes@dangerouslyinc.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
James Bowes authored and Junio C Hamano committed Mar 27, 2007
1 parent aa4cfa8 commit c6e0caa
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions help.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ static int term_columns(void)
return 80;
}

static void oom(void)
{
fprintf(stderr, "git: out of memory\n");
exit(1);
}

static inline void mput_char(char c, unsigned int num)
{
while(num--)
Expand All @@ -54,13 +48,9 @@ static void add_cmdname(const char *name, int len)
struct cmdname *ent;
if (cmdname_alloc <= cmdname_cnt) {
cmdname_alloc = cmdname_alloc + 200;
cmdname = realloc(cmdname, cmdname_alloc * sizeof(*cmdname));
if (!cmdname)
oom();
cmdname = xrealloc(cmdname, cmdname_alloc * sizeof(*cmdname));
}
ent = xmalloc(sizeof(*ent) + len);
if (!ent)
oom();
ent->len = len;
memcpy(ent->name, name, len);
ent->name[len] = 0;
Expand Down

0 comments on commit c6e0caa

Please sign in to comment.