X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftally%2Ftally.c;h=d67112c2cf6da49017904be9ec91b49f1f11ced5;hp=a5eedcb951bfafc819701a740bcad64e68f162ac;hb=237fc67d26def3f4458594b4aff7cb617f4522f7;hpb=b10913e2abf41d97a3a7b4a00cc0909986d947d5;ds=sidebyside diff --git a/ccan/tally/tally.c b/ccan/tally/tally.c index a5eedcb9..d67112c2 100644 --- a/ccan/tally/tally.c +++ b/ccan/tally/tally.c @@ -25,12 +25,15 @@ struct tally *tally_new(unsigned buckets) struct tally *tally; /* There is always 1 bucket. */ - if (buckets == 0) + if (buckets == 0) { buckets = 1; + } /* Overly cautious check for overflow. */ - if (sizeof(*tally) * buckets / sizeof(*tally) != buckets) + if (sizeof(*tally) * buckets / sizeof(*tally) != buckets) { return NULL; + } + tally = (struct tally *)malloc( sizeof(*tally) + sizeof(tally->counts[0])*(buckets-1)); if (tally == NULL) {