From: Ruben Kerkhof Date: Fri, 1 Apr 2016 16:03:50 +0000 (+0200) Subject: oracle plugin: malloc + memset -> calloc X-Git-Tag: collectd-5.6.0~371^2~24 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6e6efef36b63acffa8d83f1d778db799c6ab5bc0;p=collectd.git oracle plugin: malloc + memset -> calloc --- diff --git a/src/oracle.c b/src/oracle.c index fedefd09..3e4653d5 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -198,13 +198,12 @@ static int o_config_add_database (oconfig_item_t *ci) /* {{{ */ return (-1); } - db = malloc (sizeof (*db)); + db = calloc (1, sizeof (*db)); if (db == NULL) { - ERROR ("oracle plugin: malloc failed."); + ERROR ("oracle plugin: calloc failed."); return (-1); } - memset (db, 0, sizeof (*db)); db->name = NULL; db->host = NULL; db->connect_id = NULL; @@ -502,13 +501,12 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ #define ALLOC_OR_FAIL(ptr, ptr_size) \ do { \ size_t alloc_size = (size_t) ((ptr_size)); \ - (ptr) = malloc (alloc_size); \ + (ptr) = calloc (1, alloc_size); \ if ((ptr) == NULL) { \ FREE_ALL; \ - ERROR ("oracle plugin: o_read_database_query: malloc failed."); \ + ERROR ("oracle plugin: o_read_database_query: calloc failed."); \ return (-1); \ } \ - memset ((ptr), 0, alloc_size); \ } while (0) /* Initialize everything to NULL so the above works. */