particles: use calloc() instead of malloc()

In cases where it makes sense, use calloc() instead of malloc():

* When allocating large objects with many members, many for which
  NULL/0 is a good default value.
* Arrays etc where we explicitly initialize to NULL anyway.
This commit is contained in:
Daniel Eklöf 2019-02-09 11:05:12 +01:00
parent 29e9cea1dd
commit 6bba9200cf
7 changed files with 16 additions and 23 deletions

View file

@ -98,10 +98,10 @@ struct exposable *
dynlist_exposable_new(struct exposable **exposables, size_t count,
int left_spacing, int right_spacing)
{
struct private *e = malloc(sizeof(*e));
struct private *e = calloc(1, sizeof(*e));
e->count = count;
e->exposables = malloc(count * sizeof(e->exposables[0]));
e->widths = malloc(count * sizeof(e->widths[0]));
e->widths = calloc(count, sizeof(e->widths[0]));
e->left_spacing = left_spacing;
e->right_spacing = right_spacing;