};
typedef struct ts_data_s ts_data_t;
-int ts_util_get_key_and_string_wo_strdup (const oconfig_item_t *ci, char **ret_key, char **ret_string) /* {{{ */
+static int ts_util_get_key_and_string_wo_strdup (const oconfig_item_t *ci, char **ret_key, char **ret_string) /* {{{ */
{
if ((ci->values_num != 2)
|| (ci->values[0].type != OCONFIG_TYPE_STRING)
return (-1);
}
- if(NULL == (*dest)) {
+ if ((*dest) == NULL)
+ {
// Create a new meta_data_t
- if( NULL == (*dest = meta_data_create())) {
+ if ((*dest = meta_data_create()) == NULL)
+ {
ERROR ("Target `set': failed to create a meta data for `%s'.", ci->key);
return (-1);
}
}
- return(meta_data_add_string (*dest, key, string));
+ return (meta_data_add_string (*dest, key, string));
} /* }}} int ts_config_add_meta */
static int ts_destroy (void **user_data) /* {{{ */
int status;
int i;
- data = (ts_data_t *) malloc (sizeof (*data));
+ data = calloc (1, sizeof (*data));
if (data == NULL)
{
- ERROR ("ts_create: malloc failed.");
+ ERROR ("ts_create: calloc failed.");
return (-ENOMEM);
}
- memset (data, 0, sizeof (*data));
data->host = NULL;
data->plugin = NULL;
status = ts_config_add_string (&data->type, child,
/* may be empty = */ 0);
#endif
+ else if (strcasecmp ("TypeInstance", child->key) == 0)
+ status = ts_config_add_string (&data->type_instance, child,
+ /* may be empty = */ 1);
else if (strcasecmp ("MetaDataSet", child->key) == 0)
status = ts_config_add_meta (&data->meta, child,
/* may be empty = */ 1);
return (-EINVAL);
}
- if(NULL != data->meta) {
+ if (data->meta != NULL)
+ {
meta_data_clone_merge(&(vl->meta), data->meta);
}