malloc + memset -> zalloc

And for clients using the xmalloc helper, use xzalloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2013-08-08 11:57:05 +10:00
committed by Kristian Høgsberg
parent b1bc4a68b0
commit f3d62276d2
35 changed files with 68 additions and 138 deletions
+1 -2
View File
@@ -283,10 +283,9 @@ clipboard_create(struct weston_seat *seat)
{
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;
+1 -2
View File
@@ -494,10 +494,9 @@ module_init(struct weston_compositor *ec,
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();
+1 -2
View File
@@ -94,10 +94,9 @@ module_init(struct weston_compositor *ec,
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;
+4 -8
View File
@@ -234,7 +234,7 @@ drm_fb_create_dumb(struct drm_compositor *ec, unsigned width, unsigned height)
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 @@ create_output_for_connector(struct drm_compositor *ec,
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 @@ create_sprites(struct drm_compositor *ec)
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 @@ create_sprites(struct drm_compositor *ec)
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 @@ drm_compositor_create(struct wl_display *display,
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. */
+2 -5
View File
@@ -95,10 +95,9 @@ headless_compositor_create_output(struct headless_compositor *c,
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 @@ headless_compositor_create(struct wl_display *display,
{
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;
+2 -5
View File
@@ -445,10 +445,9 @@ rdp_compositor_create_output(struct rdp_compositor *c, int width, int height,
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 @@ rdp_compositor_create(struct wl_display *display,
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;
+1 -2
View File
@@ -598,11 +598,10 @@ evdev_input_create(struct weston_compositor *c, struct udev *udev,
{
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;
+3 -8
View File
@@ -249,10 +249,9 @@ wayland_compositor_create_output(struct wayland_compositor *c,
{
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 @@ display_add_seat(struct wayland_compositor *c, uint32_t id)
{
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 @@ wayland_compositor_create(struct wl_display *display,
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;
+2 -6
View File
@@ -813,12 +813,10 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
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 @@ x11_compositor_create(struct wl_display *display,
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;
+1 -3
View File
@@ -1077,9 +1077,7 @@ weston_buffer_from_resource(struct wl_resource *resource)
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;
+1 -2
View File
@@ -382,13 +382,12 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
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;
+1 -2
View File
@@ -552,10 +552,9 @@ evdev_device_create(struct weston_seat *seat, const char *path, int device_fd)
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 =
+3 -6
View File
@@ -307,11 +307,10 @@ weston_pointer_create(void)
{
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 @@ weston_keyboard_create(void)
{
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 @@ weston_touch_create(void)
{
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;
+1 -2
View File
@@ -465,12 +465,11 @@ weston_recorder_create(struct weston_output *output, const char *filename)
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;
+1 -2
View File
@@ -4443,11 +4443,10 @@ module_init(struct weston_compositor *ec,
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;
+1 -2
View File
@@ -527,11 +527,10 @@ module_init(struct weston_compositor *compositor,
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;
+1 -2
View File
@@ -132,11 +132,10 @@ tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
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;
+1 -2
View File
@@ -338,11 +338,10 @@ udev_seat_create(struct weston_compositor *c, const char *seat_name)
{
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;
+1 -3
View File
@@ -325,9 +325,7 @@ module_init(struct weston_compositor *compositor,
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;
+2 -4
View File
@@ -990,7 +990,7 @@ weston_wm_window_create(struct weston_wm *wm,
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 @@ weston_wm_window_create(struct weston_wm *wm,
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 @@ weston_wm_create(struct weston_xserver *wxs)
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) {