mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-06-16 08:15:40 +02:00
modules: 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:
parent
6bba9200cf
commit
b6e61f9c7e
11 changed files with 12 additions and 58 deletions
|
@ -269,13 +269,10 @@ err:
|
|||
static struct module *
|
||||
alsa_new(const char *card, const char *mixer, struct particle *label)
|
||||
{
|
||||
struct private *priv = malloc(sizeof(*priv));
|
||||
struct private *priv = calloc(1, sizeof(*priv));
|
||||
priv->label = label;
|
||||
priv->card = strdup(card);
|
||||
priv->mixer = strdup(mixer);
|
||||
memset(&priv->channels, 0, sizeof(priv->channels));
|
||||
priv->vol_cur = priv->vol_min = priv->vol_max = 0;
|
||||
priv->muted = true;
|
||||
|
||||
struct module *mod = module_common_new();
|
||||
mod->private = priv;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue