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:
@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user