- tally = malloc(sizeof(*tally) + sizeof(tally->counts[0])*buckets);
- if (tally) {
- /* SSIZE_MAX isn't portable, so make it one of these types. */
- BUILD_ASSERT(sizeof(tally->min) == sizeof(int)
- || sizeof(tally->min) == sizeof(long)
- || sizeof(tally->min) == sizeof(long long));
- if (sizeof(tally->min) == sizeof(int)) {
- tally->min = INT_MAX;
- tally->max = INT_MIN;
- } else if (sizeof(tally->min) == sizeof(long)) {
- tally->min = LONG_MAX;
- tally->max = LONG_MIN;
- } else if (sizeof(tally->min) == sizeof(long long)) {
- tally->min = (ssize_t)LLONG_MAX;
- tally->max = (ssize_t)LLONG_MIN;
- }
- tally->total[0] = tally->total[1] = 0;
- /* There is always 1 bucket. */
- tally->buckets = buckets+1;
- tally->step_bits = 0;
- memset(tally->counts, 0, sizeof(tally->counts[0])*(buckets+1));