avoid asking ?alloc() for zero bytes.

Avoid asking for zero bytes when that change simplifies overall
logic.  Later we would change the wrapper to ask for 1 byte on
platforms that return NULL for zero byte request.

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Junio C Hamano
2005-12-26 12:34:56 -08:00
parent 7d6fb370bc
commit 7e4a2a8483
6 changed files with 39 additions and 19 deletions

View File

@ -263,6 +263,10 @@ void diff_tree_setup_paths(const char **p)
paths = p;
nr_paths = count_paths(paths);
if (nr_paths == 0) {
pathlens = NULL;
return;
}
pathlens = xmalloc(nr_paths * sizeof(int));
for (i=0; i<nr_paths; i++)
pathlens[i] = strlen(paths[i]);