diff options
author | Volker Lendecke <vl@samba.org> | 2011-08-10 19:44:10 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2011-08-10 19:56:10 +0200 |
commit | 066d36a1a635e1115f62c452c49a9830d484c03b (patch) | |
tree | cf2e8db17e3e4d3aa5d2b3e5127c00eb736d0452 | |
parent | cb5c6f441f394f91bedf641aa76841bdb833e440 (diff) | |
download | samba-066d36a1a635e1115f62c452c49a9830d484c03b.tar.gz samba-066d36a1a635e1115f62c452c49a9830d484c03b.tar.bz2 samba-066d36a1a635e1115f62c452c49a9830d484c03b.zip |
Slightly simplify tally_new
-rw-r--r-- | lib/ccan/tally/tally.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/ccan/tally/tally.c b/lib/ccan/tally/tally.c index 2af7353380..a5eedcb951 100644 --- a/lib/ccan/tally/tally.c +++ b/lib/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; } |