summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6075508)
raw | patch | inline | side by side (parent: 6075508)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 1 Apr 2016 15:02:13 +0000 (17:02 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 1 Apr 2016 15:02:13 +0000 (17:02 +0200) |
src/liboconfig/oconfig.c | patch | blob | history | |
src/liboconfig/parser.y | patch | blob | history |
index 48f0b25f54dc57807931c82f6d437352d5e457da..b4b8244281ff79b5f476572ada48ddc3715ad526 100644 (file)
--- a/src/liboconfig/oconfig.c
+++ b/src/liboconfig/oconfig.c
{
oconfig_item_t *ci_copy;
- ci_copy = 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;
index 57e9ddffc770041e134a670897c8036fa001ca6e..1eb7aecee0cade45c59f34a001d110caaa26093e 100644 (file)
--- a/src/liboconfig/parser.y
+++ b/src/liboconfig/parser.y
entire_file:
statement_list
{
- ci_root = malloc (sizeof (*ci_root));
- memset (ci_root, '\0', sizeof (*ci_root));
+ ci_root = calloc (1, sizeof (*ci_root));
ci_root->children = $1.statement;
ci_root->children_num = $1.statement_num;
}
| /* epsilon */
{
- ci_root = malloc (sizeof (*ci_root));
- memset (ci_root, '\0', sizeof (*ci_root));
+ ci_root = calloc (1, sizeof (*ci_root));
ci_root->children = NULL;
ci_root->children_num = 0;
}