summaryrefslogtreecommitdiff
path: root/commit-tree.c
diff options
context:
space:
mode:
authorLibravatar Christopher Li <git@chrisli.org>2005-04-26 12:00:58 -0700
committerLibravatar Linus Torvalds <torvalds@ppc970.osdl.org>2005-04-26 12:00:58 -0700
commit812666c8e66a21e668c0789d0422aa5a7db54961 (patch)
treeb98a096f4b3c70aac3110f905a1367c23b402cca /commit-tree.c
parentupdate-cache: remove index lock file on SIGINT (diff)
downloadtgif-812666c8e66a21e668c0789d0422aa5a7db54961.tar.xz
[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 'commit-tree.c')
-rw-r--r--commit-tree.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/commit-tree.c b/commit-tree.c
index f6e4087560..23de133619 100644
--- a/commit-tree.c
+++ b/commit-tree.c
@@ -18,7 +18,7 @@
*/
static void init_buffer(char **bufp, unsigned int *sizep)
{
- char *buf = malloc(BLOCKING);
+ char *buf = xmalloc(BLOCKING);
*sizep = 0;
*bufp = buf;
}
@@ -40,7 +40,7 @@ static void add_buffer(char **bufp, unsigned int *sizep, const char *fmt, ...)
buf = *bufp;
if (newsize > alloc) {
alloc = (newsize + 32767) & ~32767;
- buf = realloc(buf, alloc);
+ buf = xrealloc(buf, alloc);
*bufp = buf;
}
*sizep = newsize;