summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 75754ce)
raw | patch | inline | side by side (parent: 75754ce)
author | Florian Forster <octo@collectd.org> | |
Thu, 2 Feb 2012 16:43:28 +0000 (17:43 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 2 Feb 2012 17:18:06 +0000 (18:18 +0100) |
Just leave them at NULL and catch this condition in wg_format_name().
src/write_graphite.c | patch | blob | history |
diff --git a/src/write_graphite.c b/src/write_graphite.c
index c658e207bde001a529b32e1f0f50cf36764573a8..827ec3881263a749eeb68d89c50d7a357a185ac4 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
assert (plugin != NULL);
assert (type != NULL);
+ if (prefix == NULL)
+ prefix = "";
+
+ if (postfix == NULL)
+ postfix = "";
+
if ((n_hostname = malloc(strlen(hostname)+1)) == NULL)
{
ERROR ("Unable to allocate memory for normalized hostname buffer");
}
}
- if (cb->prefix == NULL) {
- if ((cb->prefix = malloc((int)sizeof(char))) == NULL)
- {
- ERROR ("Unable to allocate memory for hostname prefix buffer");
- return (-1);
- }
- cb->prefix[0] = '\0';
- }
-
- if (cb->postfix == NULL) {
- if ((cb->postfix = malloc((int)sizeof(char))) == NULL)
- {
- ERROR ("Unable to allocate memory for hostname postfix buffer");
- return (-1);
- }
- cb->postfix[0] = '\0';
- }
-
DEBUG ("write_graphite: Registering write callback to carbon agent %s:%s",
cb->node ? cb->node : WG_DEFAULT_NODE,
cb->service ? cb->service : WG_DEFAULT_SERVICE);