mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-06-16 08:15:40 +02:00
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:
parent
29e9cea1dd
commit
6bba9200cf
7 changed files with 16 additions and 23 deletions
|
@ -111,7 +111,7 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
|||
pp = p->default_particle;
|
||||
}
|
||||
|
||||
struct eprivate *e = malloc(sizeof(*e));
|
||||
struct eprivate *e = calloc(1, sizeof(*e));
|
||||
e->exposable = pp->instantiate(pp, tags);
|
||||
|
||||
char *on_click = tags_expand_template(particle->on_click_template, tags);
|
||||
|
@ -151,7 +151,7 @@ map_new(struct particle *common, const char *tag,
|
|||
const struct particle_map particle_map[], size_t count,
|
||||
struct particle *default_particle)
|
||||
{
|
||||
struct private *priv = malloc(sizeof(*priv));
|
||||
struct private *priv = calloc(1, sizeof(*priv));
|
||||
priv->tag = strdup(tag);
|
||||
priv->default_particle = default_particle;
|
||||
priv->count = count;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue