From 7996df8d6567eec464f5d4c427515daefe8e2373 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 28 Jan 2006 18:59:18 +0000 Subject: Use xcalloc function to simplify config parsing. --- daemon/config.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'daemon/config.c') 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 */ -- cgit v1.2.3