From 812666c8e66a21e668c0789d0422aa5a7db54961 Mon Sep 17 00:00:00 2001 From: Christopher Li Date: Tue, 26 Apr 2005 12:00:58 -0700 Subject: [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 Signed-off-by: Linus Torvalds --- commit-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'commit-tree.c') diff --git a/commit-tree.c b/commit-tree.c index f6e408756..23de13361 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; -- cgit v1.2.1