summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-01-28 18:59:18 +0000
committerStef Walter <stef@memberwebs.com>2006-01-28 18:59:18 +0000
commit7996df8d6567eec464f5d4c427515daefe8e2373 (patch)
treef8381eec9c0c43853b24ffd768b54fbd277c159d /daemon
parentdd192cc2ac301972f6761f5d6bd3a4c6a46736bf (diff)
Use xcalloc function to simplify config parsing.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/config.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/daemon/config.c b/daemon/config.c
index e6a61c2..8c20c4a 100644
--- a/daemon/config.c
+++ b/daemon/config.c
@@ -146,9 +146,8 @@ config_done(config_ctx* ctx)
poll = (rb_poller*)hsh_get(g_state.poll_by_key, key, -1);
if(!poll)
{
- poll = (rb_poller*)calloc(1, sizeof(*poll));
-
- if(!poll || !hsh_set(g_state.poll_by_key, key, -1, poll))
+ poll = (rb_poller*)xcalloc(sizeof(*poll));
+ if(!hsh_set(g_state.poll_by_key, key, -1, poll))
errx(1, "out of memory");
strcpy(poll->key, key);
@@ -264,9 +263,8 @@ parse_item(const char* field, char* uri, config_ctx *ctx)
if(!rhost)
{
/* Make a new one if necessary */
- rhost = (rb_host*)calloc(1, sizeof(*rhost));
-
- if(!rhost || !hsh_set(g_state.host_by_name, host, -1, rhost))
+ rhost = (rb_host*)xcalloc(sizeof(*rhost));
+ if(!hsh_set(g_state.host_by_name, host, -1, rhost))
errx(1, "out of memory");
/* TODO: Version support */
@@ -290,10 +288,7 @@ parse_item(const char* field, char* uri, config_ctx *ctx)
}
/* Make a new item */
- ritem = calloc(1, sizeof(*ritem));
- if(!ritem)
- errx(1, "out of memory");
-
+ ritem = (rb_item*)xcalloc(sizeof(*ritem));
ritem->rrdfield = field;
ritem->host = rhost;
ritem->poller = NULL; /* Set later in config_done */