summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f7958d7)
raw | patch | inline | side by side (parent: f7958d7)
author | Scott Sanders <scott@jssjr.com> | |
Mon, 3 Oct 2011 00:18:41 +0000 (20:18 -0400) | ||
committer | Scott Sanders <scott@jssjr.com> | |
Mon, 3 Oct 2011 00:18:41 +0000 (20:18 -0400) |
src/write_graphite.c | patch | blob | history |
diff --git a/src/write_graphite.c b/src/write_graphite.c
index 870ce2bbb72dd991a3b2cc82ad8607d931178a7c..a468665292b177b8ae317f3ec87f6864b2222a35 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
{
int status;
char *n_hostname = 0;
- char *n_ds_name = 0;
+ char *n_type_instance = 0;
assert (plugin != NULL);
assert (type != NULL);
return (-1);
}
- if ((n_ds_name = malloc(strlen(ds_name)+1)) == NULL)
- {
- ERROR ("Unable to allocate memory for normalized datasource name buffer");
- return (-1);
- }
-
- if (ds_name && ds_name[0] != '\0') {
- if (mangle_dots(n_ds_name, ds_name) == -1)
+ if (type_instance && type_instance[0] != '\0') {
+ if ((n_type_instance = malloc(strlen(type_instance)+1)) == NULL)
+ {
+ ERROR ("Unable to allocate memory for normalized datasource name buffer");
+ return (-1);
+ }
+ if (mangle_dots(n_type_instance, type_instance) == -1)
{
ERROR ("Unable to normalize datasource name");
return (-1);
if ((plugin_instance == NULL) || (plugin_instance[0] == '\0'))
{
- if ((type_instance == NULL) || (type_instance[0] == '\0'))
+ if ((n_type_instance == NULL) || (n_type_instance[0] == '\0'))
{
if ((ds_name == NULL) || (ds_name[0] == '\0'))
status = ssnprintf (ret, ret_len, "%s.%s.%s.%s",
prefix, n_hostname, plugin, type);
else
status = ssnprintf (ret, ret_len, "%s.%s.%s.%s.%s",
- prefix, n_hostname, plugin, type, n_ds_name);
+ prefix, n_hostname, plugin, type, ds_name);
}
else
{
if ((ds_name == NULL) || (ds_name[0] == '\0'))
status = ssnprintf (ret, ret_len, "%s.%s.%s.%s-%s",
prefix, n_hostname, plugin, type,
- type_instance);
+ n_type_instance);
else
status = ssnprintf (ret, ret_len, "%s.%s.%s.%s-%s.%s",
prefix, n_hostname, plugin, type,
- type_instance, n_ds_name);
+ n_type_instance, ds_name);
}
}
else
{
- if ((type_instance == NULL) || (type_instance[0] == '\0'))
+ if ((n_type_instance == NULL) || (n_type_instance[0] == '\0'))
{
if ((ds_name == NULL) || (ds_name[0] == '\0'))
status = ssnprintf (ret, ret_len, "%s.%s.%s.%s.%s",
else
status = ssnprintf (ret, ret_len, "%s.%s.%s.%s.%s.%s",
prefix, n_hostname, plugin,
- plugin_instance, type, n_ds_name);
+ plugin_instance, type, ds_name);
}
else
{
if ((ds_name == NULL) || (ds_name[0] == '\0'))
status = ssnprintf (ret, ret_len, "%s.%s.%s.%s.%s-%s",
prefix, n_hostname, plugin,
- plugin_instance, type, type_instance);
+ plugin_instance, type, n_type_instance);
else
status = ssnprintf (ret, ret_len, "%s.%s.%s.%s.%s-%s.%s",
prefix, n_hostname, plugin,
- plugin_instance, type, type_instance, n_ds_name);
+ plugin_instance, type, n_type_instance, ds_name);
}
}
sfree(n_hostname);
- sfree(n_ds_name);
+ sfree(n_type_instance);
if ((status < 1) || (status >= ret_len))
return (-1);