[PATCH weston] Use [x]zalloc instead of [x]malloc + memset
Derek Foreman
derekf at osg.samsung.com
Fri Aug 7 08:50:20 PDT 2015
These all look good to me.
Reviewed-by: Derek Foreman <derekf at osg.samsung.com>
On 07/08/15 06:20 AM, Ryo Munakata wrote:
> Signed-off-by: Ryo Munakata <ryomnktml at gmail.com>
> ---
> clients/editor.c | 3 +--
> clients/subsurfaces.c | 6 ++----
> fullscreen-shell/fullscreen-shell.c | 9 +++------
> 3 files changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/clients/editor.c b/clients/editor.c
> index d0b7fee..7d388a4 100644
> --- a/clients/editor.c
> +++ b/clients/editor.c
> @@ -687,8 +687,7 @@ text_entry_create(struct editor *editor, const char *text)
> {
> struct text_entry *entry;
>
> - entry = xmalloc(sizeof *entry);
> - memset(entry, 0, sizeof *entry);
> + entry = xzalloc(sizeof *entry);
>
> entry->widget = widget_add_widget(editor->widget, entry);
> entry->window = editor->window;
> diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c
> index 32179db..b971fdf 100644
> --- a/clients/subsurfaces.c
> +++ b/clients/subsurfaces.c
> @@ -498,8 +498,7 @@ triangle_create(struct window *window, struct egl_state *egl)
> {
> struct triangle *tri;
>
> - tri = xmalloc(sizeof *tri);
> - memset(tri, 0, sizeof *tri);
> + tri = xzalloc(sizeof *tri);
>
> tri->egl = egl;
> tri->widget = window_add_subsurface(window, tri,
> @@ -720,8 +719,7 @@ demoapp_create(struct display *display)
> {
> struct demoapp *app;
>
> - app = xmalloc(sizeof *app);
> - memset(app, 0, sizeof *app);
> + app = xzalloc(sizeof *app);
>
> app->egl = egl_state_create(display_get_display(display));
>
> diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c
> index ef9302b..fa0bf8c 100644
> --- a/fullscreen-shell/fullscreen-shell.c
> +++ b/fullscreen-shell/fullscreen-shell.c
> @@ -142,10 +142,9 @@ seat_created(struct wl_listener *l, void *data)
> struct weston_seat *seat = data;
> struct pointer_focus_listener *listener;
>
> - listener = malloc(sizeof *listener);
> + listener = zalloc(sizeof *listener);
> if (!listener)
> return;
> - memset(listener, 0, sizeof *listener);
>
> listener->shell = container_of(l, struct fullscreen_shell,
> seat_created_listener);
> @@ -251,10 +250,9 @@ fs_output_create(struct fullscreen_shell *shell, struct weston_output *output)
> {
> struct fs_output *fsout;
>
> - fsout = malloc(sizeof *fsout);
> + fsout = zalloc(sizeof *fsout);
> if (!fsout)
> return NULL;
> - memset(fsout, 0, sizeof *fsout);
>
> fsout->shell = shell;
> wl_list_insert(&shell->output_list, &fsout->link);
> @@ -805,11 +803,10 @@ module_init(struct weston_compositor *compositor,
> struct weston_seat *seat;
> struct weston_output *output;
>
> - shell = malloc(sizeof *shell);
> + shell = zalloc(sizeof *shell);
> if (shell == NULL)
> return -1;
>
> - memset(shell, 0, sizeof *shell);
> shell->compositor = compositor;
>
> shell->client_destroyed.notify = client_destroyed;
>
More information about the wayland-devel
mailing list