mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-06-16 00:05: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
10
module.c
10
module.c
|
@ -6,17 +6,9 @@
|
|||
struct module *
|
||||
module_common_new(void)
|
||||
{
|
||||
struct module *mod = malloc(sizeof(*mod));
|
||||
mod->bar = NULL;
|
||||
struct module *mod = calloc(1, sizeof(*mod));
|
||||
mtx_init(&mod->lock, mtx_plain);
|
||||
mod->private = NULL;
|
||||
mod->destroy = &module_default_destroy;
|
||||
|
||||
/* No defaults for these; must be provided by implementation */
|
||||
mod->run = NULL;
|
||||
mod->content = NULL;
|
||||
mod->refresh_in = NULL;
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue