aboutsummaryrefslogtreecommitdiffstats
path: root/src/event-loop.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-01-31 22:23:30 +0100
committerSimon Ser <contact@emersion.fr>2022-02-05 14:25:19 +0000
commit5eb5620cbd317aac4a61e357c3c92bd889d6079b (patch)
tree5a3953e2ff74d9ef9ad4e7d32dca9da750b80689 /src/event-loop.c
parentbuild: explicitly set check arg in run_command() (diff)
downloadwayland-5eb5620cbd317aac4a61e357c3c92bd889d6079b.tar
wayland-5eb5620cbd317aac4a61e357c3c92bd889d6079b.tar.gz
wayland-5eb5620cbd317aac4a61e357c3c92bd889d6079b.tar.bz2
wayland-5eb5620cbd317aac4a61e357c3c92bd889d6079b.tar.lz
wayland-5eb5620cbd317aac4a61e357c3c92bd889d6079b.tar.xz
wayland-5eb5620cbd317aac4a61e357c3c92bd889d6079b.tar.zst
wayland-5eb5620cbd317aac4a61e357c3c92bd889d6079b.zip
Use zalloc for structs
When allocating memory for structs, use zalloc instead of malloc. This ensures the memory is zero-initialized, and reduces the risk of forgetting to initialize all struct fields. Signed-off-by: Simon Ser <contact@emersion.fr>
Diffstat (limited to 'src/event-loop.c')
-rw-r--r--src/event-loop.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/event-loop.c b/src/event-loop.c
index c7c98b0..37cf95d 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -179,7 +179,7 @@ wl_event_loop_add_fd(struct wl_event_loop *loop,
{
struct wl_event_source_fd *source;
- source = malloc(sizeof *source);
+ source = zalloc(sizeof *source);
if (source == NULL)
return NULL;
@@ -568,7 +568,7 @@ wl_event_loop_add_timer(struct wl_event_loop *loop,
if (wl_timer_heap_ensure_timerfd(&loop->timers) < 0)
return NULL;
- source = malloc(sizeof *source);
+ source = zalloc(sizeof *source);
if (source == NULL)
return NULL;
@@ -718,7 +718,7 @@ wl_event_loop_add_signal(struct wl_event_loop *loop,
struct wl_event_source_signal *source;
sigset_t mask;
- source = malloc(sizeof *source);
+ source = zalloc(sizeof *source);
if (source == NULL)
return NULL;
@@ -775,7 +775,7 @@ wl_event_loop_add_idle(struct wl_event_loop *loop,
{
struct wl_event_source_idle *source;
- source = malloc(sizeof *source);
+ source = zalloc(sizeof *source);
if (source == NULL)
return NULL;
@@ -885,7 +885,7 @@ wl_event_loop_create(void)
{
struct wl_event_loop *loop;
- loop = malloc(sizeof *loop);
+ loop = zalloc(sizeof *loop);
if (loop == NULL)
return NULL;