summaryrefslogtreecommitdiff
path: root/write-tree.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 /write-tree.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 'write-tree.c')
-rw-r--r--write-tree.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/write-tree.c b/write-tree.c
index bb7ceedb8e..168352853d 100644
--- a/write-tree.c
+++ b/write-tree.c
@@ -26,7 +26,7 @@ static int write_tree(struct cache_entry **cachep, int maxentries, const char *b
/* Guess at some random initial size */
size = 8192;
- buffer = malloc(size);
+ buffer = xmalloc(size);
offset = 0;
nr = 0;
@@ -68,7 +68,7 @@ static int write_tree(struct cache_entry **cachep, int maxentries, const char *b
entrylen = pathlen - baselen;
if (offset + entrylen + 100 > size) {
size = alloc_nr(offset + entrylen + 100);
- buffer = realloc(buffer, size);
+ buffer = xrealloc(buffer, size);
}
offset += sprintf(buffer + offset, "%o %.*s", mode, entrylen, filename);
buffer[offset++] = 0;