aboutsummaryrefslogtreecommitdiffstats
path: root/diff.c
diff options
context:
space:
mode:
authorChristopher Li <git@chrisli.org>2005-04-26 12:00:58 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-26 12:00:58 -0700
commit812666c8e66a21e668c0789d0422aa5a7db54961 (patch)
treeb98a096f4b3c70aac3110f905a1367c23b402cca /diff.c
parentf2a19340ada1188e278d5b198d3466ed7411e2d4 (diff)
downloadgit-812666c8e66a21e668c0789d0422aa5a7db54961.tar.gz
[PATCH] introduce xmalloc and xrealloc
Introduce xmalloc and xrealloc to die gracefully with a descriptive message when out of memory, rather than taking a SIGSEGV. Signed-off-by: Christopher Li<chrislgit@chrisli.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/diff.c b/diff.c
index 9905cdb012..dd71d8346d 100644
--- a/diff.c
+++ b/diff.c
@@ -59,8 +59,7 @@ static char *sq_expand(const char *src)
if (*cp == '\'')
cnt += 3;
- if (! (buf = malloc(cnt)))
- return buf;
+ buf = xmalloc(cnt);
bp = buf;
while ((c = *src++)) {
if (c != '\'')
@@ -100,7 +99,7 @@ static void builtin_diff(const char *name,
strlen(diff_arg) +
strlen(name_1_sq) + strlen(name_2_sq)
- 5);
- char *cmd = malloc(cmd_size);
+ char *cmd = xmalloc(cmd_size);
int next_at = 0;
next_at += snprintf(cmd+next_at, cmd_size-next_at,