X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fliboconfig%2Fparser.y;h=1eb7aecee0cade45c59f34a001d110caaa26093e;hb=ff9e11ade5cfabf32c63fb19fc76cbbc4186bc5b;hp=d91df8c7acb0c7fe2b4e10ddd639b5cb7d101436;hpb=979b0fa58b2de639ff79209eff12ec17ff593483;p=collectd.git diff --git a/src/liboconfig/parser.y b/src/liboconfig/parser.y index d91df8c7..1eb7aece 100644 --- a/src/liboconfig/parser.y +++ b/src/liboconfig/parser.y @@ -36,6 +36,7 @@ static int yyerror (const char *s); /* Lexer variables */ extern int yylineno; extern char *yytext; +extern int yylex (void); extern oconfig_item_t *ci_root; extern char *c_file; @@ -207,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; } @@ -224,7 +223,7 @@ entire_file: %% static int yyerror (const char *s) { - char *text; + const char *text; if (*yytext == '\n') text = "";