From: Svetlana Shmidt Date: Tue, 28 Jul 2020 09:23:20 +0000 (+0500) Subject: add static keyword to private functions X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=674b70f2888fc08277a5d04a39347e90bc546c9d;p=thirdparty%2Fcollectd.git add static keyword to private functions --- diff --git a/src/daemon/distribution.c b/src/daemon/distribution.c index 18746e655..9214e265a 100644 --- a/src/daemon/distribution.c +++ b/src/daemon/distribution.c @@ -20,16 +20,16 @@ struct distribution_s { double total_sum; }; -size_t left_child_index(size_t node_index, size_t left, size_t right) { +static size_t left_child_index(size_t node_index, size_t left, size_t right) { return node_index + 1; } -size_t right_child_index(size_t node_index, size_t left, size_t right) { +static size_t right_child_index(size_t node_index, size_t left, size_t right) { size_t mid = (left + right) / 2; return node_index + 2 * (mid - left + 1); } -bucket_t merge_buckets(bucket_t left_child, bucket_t right_child) { +static bucket_t merge_buckets(bucket_t left_child, bucket_t right_child) { return (bucket_t) { .bucket_counter = left_child.bucket_counter + right_child.bucket_counter, .minimum = left_child.minimum, @@ -37,7 +37,7 @@ bucket_t merge_buckets(bucket_t left_child, bucket_t right_child) { }; } -void build_tree(distribution_t *d, bucket_t *buckets, size_t node_index, size_t left, size_t right) { +static void build_tree(distribution_t *d, bucket_t *buckets, size_t node_index, size_t left, size_t right) { if (left > right) return; if (left == right) { @@ -52,7 +52,7 @@ void build_tree(distribution_t *d, bucket_t *buckets, size_t node_index, size_t d->tree[node_index] = merge_buckets(d->tree[left_child], d->tree[right_child]); } -distribution_t* build_distribution_from_bucket_array(size_t num_buckets, bucket_t *bucket_array) { +static distribution_t* build_distribution_from_bucket_array(size_t num_buckets, bucket_t *bucket_array) { distribution_t *new_distribution = calloc(1, sizeof(distribution_t)); if (new_distribution == NULL) { return NULL; @@ -162,7 +162,7 @@ distribution_t* distribution_clone(distribution_t *dist) { return new_distribution; } -void update_tree(distribution_t *dist, size_t node_index, size_t left, size_t right, double gauge) { +static void update_tree(distribution_t *dist, size_t node_index, size_t left, size_t right, double gauge) { if (left > right) return; if (left == right) { diff --git a/src/daemon/distribution.h b/src/daemon/distribution.h index 0dac5cf4b..4c126b273 100644 --- a/src/daemon/distribution.h +++ b/src/daemon/distribution.h @@ -18,7 +18,7 @@ distribution_t* distribution_new_custom(size_t num_buckets, double *custom_bucke void distribution_update(distribution_t *dist, double gauge); double distribution_percentile(distribution_t *dist, double percent); double distribution_average(distribution_t *dist); -distribution_t distribution_clone(distribution_t *dist); +distribution_t* distribution_clone(distribution_t *dist); void distribution_destroy(distribution_t *d); #endif // COLLECTD_DISTRIBUTION_H