diff options
author | Junio C Hamano <junkio@cox.net> | 2005-12-26 12:34:56 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-12-26 17:23:59 -0800 |
commit | 7e4a2a848377241b8fb4f624d1151bbf2f8d5814 (patch) | |
tree | 5b7f555c6aebd9c32b97dc27f3a18723549415f3 /diffcore-order.c | |
parent | 7d6fb370bc98e5d4723103dda0829b00c79da213 (diff) | |
download | git-7e4a2a848377241b8fb4f624d1151bbf2f8d5814.tar.gz |
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>
Diffstat (limited to 'diffcore-order.c')
-rw-r--r-- | diffcore-order.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/diffcore-order.c b/diffcore-order.c index b38122361f..0bc2b22f84 100644 --- a/diffcore-order.c +++ b/diffcore-order.c @@ -105,9 +105,13 @@ static int compare_pair_order(const void *a_, const void *b_) void diffcore_order(const char *orderfile) { struct diff_queue_struct *q = &diff_queued_diff; - struct pair_order *o = xmalloc(sizeof(*o) * q->nr); + struct pair_order *o; int i; + if (!q->nr) + return; + + o = xmalloc(sizeof(*o) * q->nr); prepare_order(orderfile); for (i = 0; i < q->nr; i++) { o[i].pair = q->queue[i]; |