#include "collectd.h"
-#include "common.h"
-#include "meta_data.h"
#include "plugin.h"
-#include "utils_avltree.h"
+#include "utils/avltree/avltree.h"
+#include "utils/common/common.h"
+#include "utils/metadata/meta_data.h"
#include "utils_cache.h"
#include <assert.h>
cache_entry_t *entry;
};
-static c_avl_tree_t *cache_tree = NULL;
+static c_avl_tree_t *cache_tree;
static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER;
static int cache_compare(const cache_entry_t *a, const cache_entry_t *b) {
ce = cache_alloc(ds->ds_num);
if (ce == NULL) {
sfree(key_copy);
- ERROR("uc_insert: cache_alloc (%zu) failed.", ds->ds_num);
+ ERROR("uc_insert: cache_alloc (%" PRIsz ") failed.", ds->ds_num);
return -1;
}
ce->last_time = vl->time;
ce->last_update = cdtime();
ce->interval = vl->interval;
- ce->state = STATE_OKAY;
+ ce->state = STATE_UNKNOWN;
if (c_avl_insert(cache_tree, key_copy, ce) != 0) {
sfree(key_copy);
return -1;
} /* switch (ds->ds[i].type) */
- DEBUG("uc_update: %s: ds[%zu] = %lf", name, i, ce->values_gauge[i]);
+ DEBUG("uc_update: %s: ds[%" PRIsz "] = %lf", name, i, ce->values_gauge[i]);
} /* for (i) */
/* Update the history if it exists. */
/* This is important - the caller has no other way of knowing how many
* values are returned. */
if (ret_num != ds->ds_num) {
- ERROR("utils_cache: uc_get_rate: ds[%s] has %zu values, "
- "but uc_get_rate_by_name returned %zu.",
+ ERROR("utils_cache: uc_get_rate: ds[%s] has %" PRIsz " values, "
+ "but uc_get_rate_by_name returned %" PRIsz ".",
ds->type, ds->ds_num, ret_num);
sfree(ret);
return NULL;
pthread_mutex_lock(&cache_lock);
- if (c_avl_get(cache_tree, name, (void *) &ce) == 0) {
+ if (c_avl_get(cache_tree, name, (void *)&ce) == 0) {
assert(ce != NULL);
/* remove missing values from getval */
memcpy(ret, ce->values_raw, ret_num * sizeof(value_t));
}
}
- }
- else {
+ } else {
DEBUG("utils_cache: uc_get_value_by_name: No such value: %s", name);
status = -1;
}
/* This is important - the caller has no other way of knowing how many
* values are returned. */
- if (ret_num != (size_t) ds->ds_num) {
- ERROR("utils_cache: uc_get_value: ds[%s] has %zu values, "
- "but uc_get_value_by_name returned %zu.", ds->type, ds->ds_num,
- ret_num);
+ if (ret_num != (size_t)ds->ds_num) {
+ ERROR("utils_cache: uc_get_value: ds[%s] has %" PRIsz " values, "
+ "but uc_get_value_by_name returned %" PRIsz ".",
+ ds->type, ds->ds_num, ret_num);
sfree(ret);
return (NULL);
}
* Iterator interface
*/
uc_iter_t *uc_get_iterator(void) {
- uc_iter_t *iter;
-
- iter = (uc_iter_t *)calloc(1, sizeof(*iter));
+ uc_iter_t *iter = calloc(1, sizeof(*iter));
if (iter == NULL)
return NULL;
const value_list_t *vl, const char *key, double value)
UC_WRAP(meta_data_add_double) int uc_meta_data_add_boolean(
const value_list_t *vl, const char *key,
- _Bool value) UC_WRAP(meta_data_add_boolean)
+ bool value) UC_WRAP(meta_data_add_boolean)
int uc_meta_data_get_string(const value_list_t *vl,
const char *key,
const char *key, double *value)
UC_WRAP(meta_data_get_double) int uc_meta_data_get_boolean(
const value_list_t *vl,
- const char *key, _Bool *value)
+ const char *key, bool *value)
UC_WRAP(meta_data_get_boolean)
#undef UC_WRAP