decorations: 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 10:58:26 +01:00
parent 83591b9269
commit 29e9cea1dd
3 changed files with 6 additions and 6 deletions

View file

@ -31,11 +31,11 @@ expose(const struct deco *deco, cairo_t *cr, int x, int y, int width, int height
static struct deco *
underline_new(int size, struct rgba color)
{
struct private *priv = malloc(sizeof(*priv));
struct private *priv = calloc(1, sizeof(*priv));
priv->size = size;
priv->color = color;
struct deco *deco = malloc(sizeof(*deco));
struct deco *deco = calloc(1, sizeof(*deco));
deco->private = priv;
deco->expose = &expose;
deco->destroy = &destroy;