The libc has a function for allocating cleared memory, so use that
instead of manually clearing the memory with memset.
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
static inline struct pidlist *alloc_pidlist(void)
{
static inline struct pidlist *alloc_pidlist(void)
{
- struct pidlist *p = malloc(sizeof(*p));
+ struct pidlist *p = calloc(sizeof(*p), 1);
- memset(p, 0, sizeof(*p));
INIT_LIST_HEAD(&p->list);
return p;
INIT_LIST_HEAD(&p->list);
return p;
- map = malloc(sizeof *map);
+ map = calloc(sizeof *map, 1);
if (map == NULL)
goto err;
if (map == NULL)
goto err;
- memset(map, 0, sizeof(*map));
INIT_LIST_HEAD(&map->list);
err:
return map;
INIT_LIST_HEAD(&map->list);
err:
return map;
- map = malloc(sizeof *map);
+ map = calloc(sizeof(*map), 1);
if (map == NULL)
goto err;
if (map == NULL)
goto err;
FILE *file;
char path[512];
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;
INIT_LIST_HEAD(&process->list);
process->pid = pid;