mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-02 09:01:39 -05:00
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>
This commit is contained in:
parent
4b05ecb8f7
commit
5eb5620cbd
5 changed files with 14 additions and 14 deletions
|
|
@ -223,7 +223,7 @@ shm_pool_create_buffer(struct wl_client *client, struct wl_resource *resource,
|
|||
return;
|
||||
}
|
||||
|
||||
buffer = malloc(sizeof *buffer);
|
||||
buffer = zalloc(sizeof *buffer);
|
||||
if (buffer == NULL) {
|
||||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
|
|
@ -312,7 +312,7 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
|
|||
goto err_close;
|
||||
}
|
||||
|
||||
pool = malloc(sizeof *pool);
|
||||
pool = zalloc(sizeof *pool);
|
||||
if (pool == NULL) {
|
||||
wl_client_post_no_memory(client);
|
||||
goto err_close;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue