From: Volker Lendecke
Date: Wed, 10 Aug 2011 17:44:10 +0000 (+0200)
Subject: tally: Slightly simplify tally_new
X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=b10913e2abf41d97a3a7b4a00cc0909986d947d5;hp=a81be540c665d2e751ed06510a47b934fa075140
tally: Slightly simplify tally_new
(Imported from SAMBA commit 066d36a1a635e1115f62c452c49a9830d484c03b)
---
diff --git a/ccan/tally/tally.c b/ccan/tally/tally.c
index 2af73533..a5eedcb9 100644
--- a/ccan/tally/tally.c
+++ b/ccan/tally/tally.c
@@ -33,14 +33,16 @@ struct tally *tally_new(unsigned buckets)
return NULL;
tally = (struct tally *)malloc(
sizeof(*tally) + sizeof(tally->counts[0])*(buckets-1));
- if (tally) {
- tally->max = ((size_t)1 << (SIZET_BITS - 1));
- tally->min = ~tally->max;
- tally->total[0] = tally->total[1] = 0;
- tally->buckets = buckets;
- tally->step_bits = 0;
- memset(tally->counts, 0, sizeof(tally->counts[0])*buckets);
+ if (tally == NULL) {
+ return NULL;
}
+
+ tally->max = ((size_t)1 << (SIZET_BITS - 1));
+ tally->min = ~tally->max;
+ tally->total[0] = tally->total[1] = 0;
+ tally->buckets = buckets;
+ tally->step_bits = 0;
+ memset(tally->counts, 0, sizeof(tally->counts[0])*buckets);
return tally;
}