Commit 237fc67d authored by Volker Lendecke's avatar Volker Lendecke Committed by Rusty Russell

tally: Adapt tally_new to Samba coding conventions

(Imported from SAMBA commit c6ae297d613fc22b92c34d26c61ec1715058b484)
parent b10913e2
...@@ -25,12 +25,15 @@ struct tally *tally_new(unsigned buckets) ...@@ -25,12 +25,15 @@ struct tally *tally_new(unsigned buckets)
struct tally *tally; struct tally *tally;
/* There is always 1 bucket. */ /* There is always 1 bucket. */
if (buckets == 0) if (buckets == 0) {
buckets = 1; buckets = 1;
}
/* Overly cautious check for overflow. */ /* Overly cautious check for overflow. */
if (sizeof(*tally) * buckets / sizeof(*tally) != buckets) if (sizeof(*tally) * buckets / sizeof(*tally) != buckets) {
return NULL; return NULL;
}
tally = (struct tally *)malloc( tally = (struct tally *)malloc(
sizeof(*tally) + sizeof(tally->counts[0])*(buckets-1)); sizeof(*tally) + sizeof(tally->counts[0])*(buckets-1));
if (tally == NULL) { if (tally == NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment