]> git.itanic.dy.fi Git - scan-pagemap/blobdiff - parse.c
Replace malloc + memset with calloc
[scan-pagemap] / parse.c
diff --git a/parse.c b/parse.c
index 9241526969727ca9dffdffba1cd4c9fd03376e75..5f3196c50cbfe1b242b2b0d846184c2a25b91d97 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -32,11 +32,10 @@ static struct maps_list *alloc_maplist(void)
 {
        struct maps_list *map;
 
-       map = malloc(sizeof *map);
+       map = calloc(sizeof *map, 1);
        if (map == NULL)
                goto err;
 
-       memset(map, 0, sizeof(*map));
        INIT_LIST_HEAD(&map->list);
 err:
        return map;
@@ -46,7 +45,7 @@ static struct maps *alloc_map(void)
 {
        struct maps *map;
 
-       map = malloc(sizeof *map);
+       map = calloc(sizeof(*map), 1);
        if (map == NULL)
                goto err;
 
@@ -283,8 +282,7 @@ static int read_pageframe(int pid, int tid, struct pageframe *pageframe,
        FILE *file;
        char path[512];
 
-       process = malloc(sizeof(*process));
-       memset(process, 0, sizeof(*process));
+       process = calloc(sizeof(*process), 1);
        INIT_LIST_HEAD(&process->list);
 
        process->pid = pid;