X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fliboconfig%2Foconfig.c;h=cfe9c5a1450fb5588c341fca56aadcc8a1f35a2f;hb=441e067a2d5a294517bd87ca45c87fd67377d2cf;hp=89ccdecb9e6e935be7eb840b8ac4a135d687de28;hpb=b758f3b7146f1497d93e1df64cbc0c14ae164768;p=collectd.git diff --git a/src/liboconfig/oconfig.c b/src/liboconfig/oconfig.c index 89ccdecb..cfe9c5a1 100644 --- a/src/liboconfig/oconfig.c +++ b/src/liboconfig/oconfig.c @@ -106,13 +106,12 @@ oconfig_item_t *oconfig_clone (const oconfig_item_t *ci_orig) { oconfig_item_t *ci_copy; - ci_copy = (oconfig_item_t *) malloc (sizeof (*ci_copy)); + ci_copy = calloc (1, sizeof (*ci_copy)); if (ci_copy == NULL) { - fprintf (stderr, "malloc failed.\n"); + fprintf (stderr, "calloc failed.\n"); return (NULL); } - memset (ci_copy, 0, sizeof (*ci_copy)); ci_copy->values = NULL; ci_copy->parent = NULL; ci_copy->children = NULL; @@ -177,7 +176,7 @@ oconfig_item_t *oconfig_clone (const oconfig_item_t *ci_orig) for (i = 0; i < ci_copy->children_num; i++) { oconfig_item_t *child; - + child = oconfig_clone (ci_orig->children + i); if (child == NULL) { @@ -222,7 +221,6 @@ void oconfig_free (oconfig_item_t *ci) { oconfig_free_all (ci); free (ci); - ci = NULL; } /*