[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>
This commit is contained in:
Christopher Li
2005-04-26 12:00:58 -07:00
committed by Linus Torvalds
parent f2a19340ad
commit 812666c8e6
18 changed files with 54 additions and 41 deletions

View File

@ -52,7 +52,7 @@ void created_object(unsigned char *sha1, struct object *obj)
if (obj_allocs == nr_objs) {
obj_allocs = alloc_nr(obj_allocs);
objs = realloc(objs, obj_allocs * sizeof(struct object *));
objs = xrealloc(objs, obj_allocs * sizeof(struct object *));
}
/* Insert it into the right place */
@ -75,7 +75,7 @@ void add_ref(struct object *refer, struct object *target)
}
target->used = 1;
p = malloc(sizeof(*p));
p = xmalloc(sizeof(*p));
p->item = target;
p->next = NULL;
*pp = p;