summaryrefslogtreecommitdiff
path: root/show-files.c
diff options
context:
space:
mode:
authorChristopher Li <git@chrisli.org>2005-04-26 19:00:58 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-26 19:00:58 (GMT)
commit812666c8e66a21e668c0789d0422aa5a7db54961 (patch)
treeb98a096f4b3c70aac3110f905a1367c23b402cca /show-files.c
parentf2a19340ada1188e278d5b198d3466ed7411e2d4 (diff)
downloadgit-812666c8e66a21e668c0789d0422aa5a7db54961.zip
git-812666c8e66a21e668c0789d0422aa5a7db54961.tar.gz
git-812666c8e66a21e668c0789d0422aa5a7db54961.tar.bz2
[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 'show-files.c')
-rw-r--r--show-files.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/show-files.c b/show-files.c
index b53ab10..afeb635 100644
--- a/show-files.c
+++ b/show-files.c
@@ -30,9 +30,9 @@ static void add_name(const char *pathname, int len)
if (nr_dir == dir_alloc) {
dir_alloc = alloc_nr(dir_alloc);
- dir = realloc(dir, dir_alloc*sizeof(char *));
+ dir = xrealloc(dir, dir_alloc*sizeof(char *));
}
- name = malloc(len + 1);
+ name = xmalloc(len + 1);
memcpy(name, pathname, len + 1);
dir[nr_dir++] = name;
}