X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Futils_db_query.c;h=74c3a81fe7c69d8052f1ce54baae71e70a6547ac;hb=8361c1e963f9184c3c4d87197fd6996d667cdb3f;hp=de435cb4e64afd40f2574b94ec06292d7bbe9aae;hpb=2facdd7eef91949c1594f06703afeb6dd87e51cc;p=collectd.git diff --git a/src/utils_db_query.c b/src/utils_db_query.c index de435cb4..74c3a81f 100644 --- a/src/utils_db_query.c +++ b/src/utils_db_query.c @@ -550,13 +550,12 @@ static int udb_result_create (const char *query_name, /* {{{ */ ci->values_num, (ci->values_num == 1) ? "" : "s"); } - r = malloc (sizeof (*r)); + r = calloc (1, sizeof (*r)); if (r == NULL) { - ERROR ("db query utils: malloc failed."); + ERROR ("db query utils: calloc failed."); return (-1); } - memset (r, 0, sizeof (*r)); r->type = NULL; r->instance_prefix = NULL; r->instances = NULL; @@ -678,13 +677,12 @@ int udb_query_create (udb_query_t ***ret_query_list, /* {{{ */ return (-1); } - q = malloc (sizeof (*q)); + q = calloc (1, sizeof (*q)); if (q == NULL) { - ERROR ("db query utils: malloc failed."); + ERROR ("db query utils: calloc failed."); return (-1); } - memset (q, 0, sizeof (*q)); q->min_version = 0; q->max_version = UINT_MAX; @@ -1072,17 +1070,16 @@ udb_query_allocate_preparation_area (udb_query_t *q) /* {{{ */ udb_result_preparation_area_t **next_r_area; udb_result_t *r; - q_area = malloc (sizeof (*q_area)); + q_area = calloc (1, sizeof (*q_area)); if (q_area == NULL) return NULL; - memset (q_area, 0, sizeof (*q_area)); next_r_area = &q_area->result_prep_areas; for (r = q->results; r != NULL; r = r->next) { udb_result_preparation_area_t *r_area; - r_area = malloc (sizeof (*r_area)); + r_area = calloc (1, sizeof (*r_area)); if (r_area == NULL) { udb_result_preparation_area_t *a = q_area->result_prep_areas; @@ -1098,8 +1095,6 @@ udb_query_allocate_preparation_area (udb_query_t *q) /* {{{ */ return NULL; } - memset (r_area, 0, sizeof (*r_area)); - *next_r_area = r_area; next_r_area = &r_area->next; }