malloc + memset -> zalloc

And for clients using the xmalloc helper, use xzalloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
diff --git a/src/clipboard.c b/src/clipboard.c
index 54f06e6..5a3a02d 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -283,10 +283,9 @@
 {
 	struct clipboard *clipboard;
 
-	clipboard = malloc(sizeof *clipboard);
+	clipboard = zalloc(sizeof *clipboard);
 	if (clipboard == NULL)
 		return NULL;
-	memset(clipboard, 0, sizeof *clipboard);
 
 	clipboard->seat = seat;
 	clipboard->selection_listener.notify = clipboard_set_selection;
diff --git a/src/cms-colord.c b/src/cms-colord.c
index 691b2e6..4ff3aac 100644
--- a/src/cms-colord.c
+++ b/src/cms-colord.c
@@ -494,10 +494,9 @@
 	weston_log("colord: initialized\n");
 
 	/* create local state object */
-	cms = malloc(sizeof *cms);
+	cms = zalloc(sizeof *cms);
 	if (cms == NULL)
 		return -1;
-	memset(cms, 0, sizeof *cms);
 	cms->ec = ec;
 #if !GLIB_CHECK_VERSION(2,36,0)
 	g_type_init();
diff --git a/src/cms-static.c b/src/cms-static.c
index 8a36ed9..ad54fd1 100644
--- a/src/cms-static.c
+++ b/src/cms-static.c
@@ -94,10 +94,9 @@
 	weston_log("cms-static: initialized\n");
 
 	/* create local state object */
-	cms = malloc(sizeof *cms);
+	cms = zalloc(sizeof *cms);
 	if (cms == NULL)
 		return -1;
-	memset(cms, 0, sizeof *cms);
 
 	cms->ec = ec;
 	cms->destroy_listener.notify = cms_notifier_destroy;
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index a47fe36..b9e3fc9 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -234,7 +234,7 @@
 	struct drm_mode_destroy_dumb destroy_arg;
 	struct drm_mode_map_dumb map_arg;
 
-	fb = calloc(1, sizeof *fb);
+	fb = zalloc(sizeof *fb);
 	if (!fb)
 		return NULL;
 
@@ -1771,11 +1771,10 @@
 		return -1;
 	}
 
-	output = malloc(sizeof *output);
+	output = zalloc(sizeof *output);
 	if (output == NULL)
 		return -1;
 
-	memset(output, 0, sizeof *output);
 	output->base.subpixel = drm_subpixel_to_wayland(connector->subpixel);
 	output->base.make = "unknown";
 	output->base.model = "unknown";
@@ -2000,7 +1999,7 @@
 		if (!plane)
 			continue;
 
-		sprite = malloc(sizeof(*sprite) + ((sizeof(uint32_t)) *
+		sprite = zalloc(sizeof(*sprite) + ((sizeof(uint32_t)) *
 						   plane->count_formats));
 		if (!sprite) {
 			weston_log("%s: out of memory\n",
@@ -2009,8 +2008,6 @@
 			continue;
 		}
 
-		memset(sprite, 0, sizeof *sprite);
-
 		sprite->possible_crtcs = plane->possible_crtcs;
 		sprite->plane_id = plane->plane_id;
 		sprite->current = NULL;
@@ -2451,10 +2448,9 @@
 
 	weston_log("initializing drm backend\n");
 
-	ec = malloc(sizeof *ec);
+	ec = zalloc(sizeof *ec);
 	if (ec == NULL)
 		return NULL;
-	memset(ec, 0, sizeof *ec);
 
 	/* KMS support for sprites is not complete yet, so disable the
 	 * functionality for now. */
diff --git a/src/compositor-headless.c b/src/compositor-headless.c
index dd33242..4a0cc7f 100644
--- a/src/compositor-headless.c
+++ b/src/compositor-headless.c
@@ -95,10 +95,9 @@
 	struct headless_output *output;
 	struct wl_event_loop *loop;
 
-	output = malloc(sizeof *output);
+	output = zalloc(sizeof *output);
 	if (output == NULL)
 		return -1;
-	memset(output, 0, sizeof *output);
 
 	output->mode.flags =
 		WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
@@ -161,12 +160,10 @@
 {
 	struct headless_compositor *c;
 
-	c = calloc(1, sizeof *c);
+	c = zalloc(sizeof *c);
 	if (c == NULL)
 		return NULL;
 
-	memset(c, 0, sizeof *c);
-
 	if (weston_compositor_init(&c->base, display, argc, argv, config) < 0)
 		goto err_free;
 
diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 33ec77d..191d673 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -445,10 +445,9 @@
 	struct wl_event_loop *loop;
 	struct weston_mode *currentMode, *next;
 
-	output = malloc(sizeof *output);
+	output = zalloc(sizeof *output);
 	if (output == NULL)
 		return -1;
-	memset(output, 0, sizeof *output);
 
 	wl_list_init(&output->peers);
 	wl_list_init(&output->base.mode_list);
@@ -991,12 +990,10 @@
 	char *fd_str;
 	int fd;
 
-	c = malloc(sizeof *c);
+	c = zalloc(sizeof *c);
 	if (c == NULL)
 		return NULL;
 
-	memset(c, 0, sizeof *c);
-
 	if (weston_compositor_init(&c->base, display, argc, argv, wconfig) < 0)
 		goto err_free;
 
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index af62b30..a0ac6d3 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -598,11 +598,10 @@
 {
 	struct rpi_seat *seat;
 
-	seat = malloc(sizeof *seat);
+	seat = zalloc(sizeof *seat);
 	if (seat == NULL)
 		return;
 
-	memset(seat, 0, sizeof *seat);
 	weston_seat_init(&seat->base, c, "default");
 	seat->base.led_update = rpi_led_update;
 
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index f3a98a8..fbaeb29 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -249,10 +249,9 @@
 {
 	struct wayland_output *output;
 
-	output = malloc(sizeof *output);
+	output = zalloc(sizeof *output);
 	if (output == NULL)
 		return -1;
-	memset(output, 0, sizeof *output);
 
 	output->mode.flags =
 		WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
@@ -629,12 +628,10 @@
 {
 	struct wayland_input *input;
 
-	input = malloc(sizeof *input);
+	input = zalloc(sizeof *input);
 	if (input == NULL)
 		return;
 
-	memset(input, 0, sizeof *input);
-
 	weston_seat_init(&input->base, &c->base, "default");
 	input->compositor = c;
 	input->seat = wl_registry_bind(c->parent.registry, id,
@@ -725,12 +722,10 @@
 	struct wl_event_loop *loop;
 	int fd;
 
-	c = malloc(sizeof *c);
+	c = zalloc(sizeof *c);
 	if (c == NULL)
 		return NULL;
 
-	memset(c, 0, sizeof *c);
-
 	if (weston_compositor_init(&c->base, display, argc, argv,
 				   config) < 0)
 		goto err_free;
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 4a73253..a896612 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -813,12 +813,10 @@
 			XCB_EVENT_MASK_KEYMAP_STATE |
 			XCB_EVENT_MASK_FOCUS_CHANGE;
 
-	output = malloc(sizeof *output);
+	output = zalloc(sizeof *output);
 	if (output == NULL)
 		return NULL;
 
-	memset(output, 0, sizeof *output);
-
 	output->mode.flags =
 		WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
 
@@ -1464,12 +1462,10 @@
 
 	weston_log("initializing x11 backend\n");
 
-	c = malloc(sizeof *c);
+	c = zalloc(sizeof *c);
 	if (c == NULL)
 		return NULL;
 
-	memset(c, 0, sizeof *c);
-
 	if (weston_compositor_init(&c->base, display, argc, argv, config) < 0)
 		goto err_free;
 
diff --git a/src/compositor.c b/src/compositor.c
index 19d84af..3213a7b 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1077,9 +1077,7 @@
 		buffer = container_of(listener, struct weston_buffer,
 				      destroy_listener);
 	} else {
-		buffer = malloc(sizeof *buffer);
-		memset(buffer, 0, sizeof *buffer);
-
+		buffer = zalloc(sizeof *buffer);
 		buffer->resource = resource;
 		wl_signal_init(&buffer->destroy_signal);
 		buffer->destroy_listener.notify = weston_buffer_destroy_handler;
diff --git a/src/data-device.c b/src/data-device.c
index a76ae16..46081d4 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -382,13 +382,12 @@
 		return;
 	}
 
-	drag = malloc(sizeof *drag);
+	drag = zalloc(sizeof *drag);
 	if (drag == NULL) {
 		wl_resource_post_no_memory(resource);
 		return;
 	}
 
-	memset(drag, 0, sizeof *drag);
 	drag->grab.interface = &drag_grab_interface;
 	drag->client = client;
 
diff --git a/src/evdev.c b/src/evdev.c
index 5ad4d6b..e9fd809 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -552,10 +552,9 @@
 	struct weston_compositor *ec;
 	char devname[256] = "unknown";
 
-	device = malloc(sizeof *device);
+	device = zalloc(sizeof *device);
 	if (device == NULL)
 		return NULL;
-	memset(device, 0, sizeof *device);
 
 	ec = seat->compositor;
 	device->output =
diff --git a/src/input.c b/src/input.c
index 7dc6b68..e533a58 100644
--- a/src/input.c
+++ b/src/input.c
@@ -307,11 +307,10 @@
 {
 	struct weston_pointer *pointer;
 
-	pointer = malloc(sizeof *pointer);
+	pointer = zalloc(sizeof *pointer);
 	if (pointer == NULL)
 		return NULL;
 
-	memset(pointer, 0, sizeof *pointer);
 	wl_list_init(&pointer->resource_list);
 	pointer->focus_listener.notify = lose_pointer_focus;
 	pointer->default_grab.interface = &default_pointer_grab_interface;
@@ -345,11 +344,10 @@
 {
 	struct weston_keyboard *keyboard;
 
-	keyboard = malloc(sizeof *keyboard);
+	keyboard = zalloc(sizeof *keyboard);
 	if (keyboard == NULL)
 	    return NULL;
 
-	memset(keyboard, 0, sizeof *keyboard);
 	wl_list_init(&keyboard->resource_list);
 	wl_array_init(&keyboard->keys);
 	keyboard->focus_listener.notify = lose_keyboard_focus;
@@ -376,11 +374,10 @@
 {
 	struct weston_touch *touch;
 
-	touch = malloc(sizeof *touch);
+	touch = zalloc(sizeof *touch);
 	if (touch == NULL)
 		return NULL;
 
-	memset(touch, 0, sizeof *touch);
 	wl_list_init(&touch->resource_list);
 	touch->focus_listener.notify = lose_touch_focus;
 	touch->default_grab.interface = &default_touch_grab_interface;
diff --git a/src/screenshooter.c b/src/screenshooter.c
index 2b37071..2414015 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -465,12 +465,11 @@
 
 	stride = output->current->width;
 	size = stride * 4 * output->current->height;
-	recorder->frame = malloc(size);
+	recorder->frame = zalloc(size);
 	recorder->rect = malloc(size);
 	recorder->total = 0;
 	recorder->count = 0;
 	recorder->output = output;
-	memset(recorder->frame, 0, size);
 
 	if (do_yflip)
 		recorder->tmpbuf = NULL;
diff --git a/src/shell.c b/src/shell.c
index 30b55c3..ebe9b9f 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -4443,11 +4443,10 @@
 	unsigned int i;
 	struct wl_event_loop *loop;
 
-	shell = malloc(sizeof *shell);
+	shell = zalloc(sizeof *shell);
 	if (shell == NULL)
 		return -1;
 
-	memset(shell, 0, sizeof *shell);
 	shell->compositor = ec;
 
 	shell->destroy_listener.notify = shell_destroy;
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index ca63b97..b055ab2 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -527,11 +527,10 @@
 	struct tablet_shell *shell;
 	struct wl_event_loop *loop;
 
-	shell = malloc(sizeof *shell);
+	shell = zalloc(sizeof *shell);
 	if (shell == NULL)
 		return -1;
 
-	memset(shell, 0, sizeof *shell);
 	shell->compositor = compositor;
 
 	shell->destroy_listener.notify = tablet_shell_destroy;
diff --git a/src/tty.c b/src/tty.c
index 38079a4..07a9405 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -132,11 +132,10 @@
 	char filename[16];
 	struct vt_stat vts;
 
-	tty = malloc(sizeof *tty);
+	tty = zalloc(sizeof *tty);
 	if (tty == NULL)
 		return NULL;
 
-	memset(tty, 0, sizeof *tty);
 	tty->compositor = compositor;
 	tty->vt_func = vt_func;
 
diff --git a/src/udev-seat.c b/src/udev-seat.c
index 771d9bc..4c051c9 100644
--- a/src/udev-seat.c
+++ b/src/udev-seat.c
@@ -338,11 +338,10 @@
 {
 	struct udev_seat *seat;
 
-	seat = malloc(sizeof *seat);
+	seat = zalloc(sizeof *seat);
 
 	if (!seat)
 		return NULL;
-	memset(seat, 0, sizeof *seat);
 	weston_seat_init(&seat->base, c, seat_name);
 	seat->base.led_update = drm_led_update;
 
diff --git a/src/xwayland/launcher.c b/src/xwayland/launcher.c
index 3228b53..b639479 100644
--- a/src/xwayland/launcher.c
+++ b/src/xwayland/launcher.c
@@ -325,9 +325,7 @@
 	struct weston_xserver *wxs;
 	char lockfile[256], display_name[8];
 
-	wxs = malloc(sizeof *wxs);
-	memset(wxs, 0, sizeof *wxs);
-
+	wxs = zalloc(sizeof *wxs);
 	wxs->process.cleanup = weston_xserver_cleanup;
 	wxs->wl_display = display;
 	wxs->compositor = compositor;
diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index 257c108..d565888 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -990,7 +990,7 @@
 	xcb_get_geometry_cookie_t geometry_cookie;
 	xcb_get_geometry_reply_t *geometry_reply;
 
-	window = malloc(sizeof *window);
+	window = zalloc(sizeof *window);
 	if (window == NULL) {
 		wm_log("failed to allocate window\n");
 		return;
@@ -1001,7 +1001,6 @@
 	values[0] = XCB_EVENT_MASK_PROPERTY_CHANGE;
 	xcb_change_window_attributes(wm->conn, id, XCB_CW_EVENT_MASK, values);
 
-	memset(window, 0, sizeof *window);
 	window->wm = wm;
 	window->id = id;
 	window->properties_dirty = 1;
@@ -1701,11 +1700,10 @@
 	int sv[2];
 	xcb_atom_t supported[3];
 
-	wm = malloc(sizeof *wm);
+	wm = zalloc(sizeof *wm);
 	if (wm == NULL)
 		return NULL;
 
-	memset(wm, 0, sizeof *wm);
 	wm->server = wxs;
 	wm->window_hash = hash_table_create();
 	if (wm->window_hash == NULL) {