short circuit out of a few places where we would allocate zero bytes

dietlibc versions of malloc, calloc and realloc all return NULL if
they're told to allocate 0 bytes, causes the x* wrappers to die().

There are several more places where these calls could end up asking
for 0 bytes, too...

Maybe simply not die()-ing in the x* wrappers if 0/NULL is returned
when the requested size is zero is a safer and easier way to go.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Eric Wong
2005-12-24 04:12:43 -08:00
committed by Junio C Hamano
parent ac44f3e7c0
commit 7d6fb370bc
2 changed files with 4 additions and 1 deletions

View File

@ -560,6 +560,9 @@ void sort_in_topological_order(struct commit_list ** list)
next = next->next;
count++;
}
if (!count)
return;
/* allocate an array to help sort the list */
nodes = xcalloc(count, sizeof(*nodes));
/* link the list to the array */