X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fliboconfig%2Fparser.y;h=4a550b32a1c8e6fa9ad89ec338a1c11c282cd25d;hb=1bdfcf9791729310f75857d0e002c40ef659a89b;hp=f0e886cc1a1e28ab5f1c277eb830c54896410d59;hpb=abc30f241619b3eb66c801c324390e1e9e6e001f;p=collectd.git diff --git a/src/liboconfig/parser.y b/src/liboconfig/parser.y index f0e886cc..4a550b32 100644 --- a/src/liboconfig/parser.y +++ b/src/liboconfig/parser.y @@ -208,15 +208,13 @@ statement_list: entire_file: statement_list { - ci_root = malloc (sizeof (oconfig_item_t)); - memset (ci_root, '\0', sizeof (oconfig_item_t)); + ci_root = calloc (1, sizeof (*ci_root)); ci_root->children = $1.statement; ci_root->children_num = $1.statement_num; } | /* epsilon */ { - ci_root = malloc (sizeof (oconfig_item_t)); - memset (ci_root, '\0', sizeof (oconfig_item_t)); + ci_root = calloc (1, sizeof (*ci_root)); ci_root->children = NULL; ci_root->children_num = 0; } @@ -225,7 +223,7 @@ entire_file: %% static int yyerror (const char *s) { - char *text; + const char *text; if (*yytext == '\n') text = ""; @@ -241,7 +239,6 @@ static char *unquote (const char *orig) { char *ret = strdup (orig); int len; - int i; if (ret == NULL) return (NULL); @@ -255,7 +252,7 @@ static char *unquote (const char *orig) memmove (ret, ret + 1, len); ret[len] = '\0'; - for (i = 0; i < len; i++) + for (int i = 0; i < len; i++) { if (ret[i] == '\\') {