treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical

This commit is contained in:
Alexander Orzechowski 2023-10-03 01:51:07 -04:00
parent a09d649439
commit 1b0694b794
99 changed files with 224 additions and 355 deletions

View File

@ -117,7 +117,7 @@ bool create_gamma_lut_blob(struct wlr_drm_backend *drm,
return true; return true;
} }
struct drm_color_lut *gamma = malloc(size * sizeof(struct drm_color_lut)); struct drm_color_lut *gamma = malloc(size * sizeof(*gamma));
if (gamma == NULL) { if (gamma == NULL) {
wlr_log(WLR_ERROR, "Failed to allocate gamma table"); wlr_log(WLR_ERROR, "Failed to allocate gamma table");
return false; return false;
@ -133,7 +133,7 @@ bool create_gamma_lut_blob(struct wlr_drm_backend *drm,
} }
if (drmModeCreatePropertyBlob(drm->fd, gamma, if (drmModeCreatePropertyBlob(drm->fd, gamma,
size * sizeof(struct drm_color_lut), blob_id) != 0) { size * sizeof(*gamma), blob_id) != 0) {
wlr_log_errno(WLR_ERROR, "Unable to create gamma LUT property blob"); wlr_log_errno(WLR_ERROR, "Unable to create gamma LUT property blob");
free(gamma); free(gamma);
return false; return false;

View File

@ -202,7 +202,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
wlr_log(WLR_INFO, "Initializing DRM backend for %s (%s)", name, version->name); wlr_log(WLR_INFO, "Initializing DRM backend for %s (%s)", name, version->name);
drmFreeVersion(version); drmFreeVersion(version);
struct wlr_drm_backend *drm = calloc(1, sizeof(struct wlr_drm_backend)); struct wlr_drm_backend *drm = calloc(1, sizeof(*drm));
if (!drm) { if (!drm) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;

View File

@ -67,8 +67,7 @@ struct wlr_drm_backend_monitor *drm_backend_monitor_create(
struct wlr_backend *multi, struct wlr_backend *multi,
struct wlr_backend *primary_drm, struct wlr_backend *primary_drm,
struct wlr_session *session) { struct wlr_session *session) {
struct wlr_drm_backend_monitor *monitor = struct wlr_drm_backend_monitor *monitor = calloc(1, sizeof(*monitor));
calloc(1, sizeof(struct wlr_drm_backend_monitor));
if (!monitor) { if (!monitor) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;

View File

@ -66,8 +66,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) { struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
wlr_log(WLR_INFO, "Creating headless backend"); wlr_log(WLR_INFO, "Creating headless backend");
struct wlr_headless_backend *backend = struct wlr_headless_backend *backend = calloc(1, sizeof(*backend));
calloc(1, sizeof(struct wlr_headless_backend));
if (!backend) { if (!backend) {
wlr_log(WLR_ERROR, "Failed to allocate wlr_headless_backend"); wlr_log(WLR_ERROR, "Failed to allocate wlr_headless_backend");
return NULL; return NULL;

View File

@ -107,8 +107,7 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
struct wlr_headless_backend *backend = struct wlr_headless_backend *backend =
headless_backend_from_backend(wlr_backend); headless_backend_from_backend(wlr_backend);
struct wlr_headless_output *output = struct wlr_headless_output *output = calloc(1, sizeof(*output));
calloc(1, sizeof(struct wlr_headless_output));
if (output == NULL) { if (output == NULL) {
wlr_log(WLR_ERROR, "Failed to allocate wlr_headless_output"); wlr_log(WLR_ERROR, "Failed to allocate wlr_headless_output");
return NULL; return NULL;

View File

@ -194,8 +194,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
struct wlr_session *session) { struct wlr_session *session) {
struct wlr_libinput_backend *backend = struct wlr_libinput_backend *backend = calloc(1, sizeof(*backend));
calloc(1, sizeof(struct wlr_libinput_backend));
if (!backend) { if (!backend) {
wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno)); wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno));
return NULL; return NULL;

View File

@ -69,8 +69,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
const char *name = libinput_device_get_name(libinput_dev); const char *name = libinput_device_get_name(libinput_dev);
wlr_log(WLR_DEBUG, "Adding %s [%d:%d]", name, vendor, product); wlr_log(WLR_DEBUG, "Adding %s [%d:%d]", name, vendor, product);
struct wlr_libinput_input_device *dev = struct wlr_libinput_input_device *dev = calloc(1, sizeof(*dev));
calloc(1, sizeof(struct wlr_libinput_input_device));
if (dev == NULL) { if (dev == NULL) {
wlr_log_errno(WLR_ERROR, "failed to allocate wlr_libinput_input_device"); wlr_log_errno(WLR_ERROR, "failed to allocate wlr_libinput_input_device");
return; return;

View File

@ -22,8 +22,7 @@ static void add_pad_group_from_libinput(struct wlr_tablet_pad *pad,
struct libinput_device *device, unsigned int index) { struct libinput_device *device, unsigned int index) {
struct libinput_tablet_pad_mode_group *li_group = struct libinput_tablet_pad_mode_group *li_group =
libinput_device_tablet_pad_get_mode_group(device, index); libinput_device_tablet_pad_get_mode_group(device, index);
struct wlr_tablet_pad_group *group = struct wlr_tablet_pad_group *group = calloc(1, sizeof(*group));
calloc(1, sizeof(struct wlr_tablet_pad_group));
if (!group) { if (!group) {
wlr_log_errno(WLR_ERROR, "failed to allocate wlr_tablet_pad_group"); wlr_log_errno(WLR_ERROR, "failed to allocate wlr_tablet_pad_group");
return; return;

View File

@ -92,7 +92,7 @@ static struct tablet_tool *get_tablet_tool(
return tool; return tool;
} }
tool = calloc(1, sizeof(struct tablet_tool)); tool = calloc(1, sizeof(*tool));
if (tool == NULL) { if (tool == NULL) {
wlr_log_errno(WLR_ERROR, "failed to allocate wlr_libinput_tablet_tool"); wlr_log_errno(WLR_ERROR, "failed to allocate wlr_libinput_tablet_tool");
return NULL; return NULL;

View File

@ -127,8 +127,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
} }
struct wlr_backend *wlr_multi_backend_create(struct wl_display *display) { struct wlr_backend *wlr_multi_backend_create(struct wl_display *display) {
struct wlr_multi_backend *backend = struct wlr_multi_backend *backend = calloc(1, sizeof(*backend));
calloc(1, sizeof(struct wlr_multi_backend));
if (!backend) { if (!backend) {
wlr_log(WLR_ERROR, "Backend allocation failed"); wlr_log(WLR_ERROR, "Backend allocation failed");
return NULL; return NULL;
@ -191,7 +190,7 @@ bool wlr_multi_backend_add(struct wlr_backend *_multi,
return true; return true;
} }
struct subbackend_state *sub = calloc(1, sizeof(struct subbackend_state)); struct subbackend_state *sub = calloc(1, sizeof(*sub));
if (sub == NULL) { if (sub == NULL) {
wlr_log(WLR_ERROR, "Could not add backend: allocation failed"); wlr_log(WLR_ERROR, "Could not add backend: allocation failed");
return false; return false;

View File

@ -257,7 +257,7 @@ static char *get_render_name(const char *name) {
wlr_log(WLR_ERROR, "drmGetDevices2 failed: %s", strerror(-devices_len)); wlr_log(WLR_ERROR, "drmGetDevices2 failed: %s", strerror(-devices_len));
return NULL; return NULL;
} }
drmDevice **devices = calloc(devices_len, sizeof(drmDevice *)); drmDevice **devices = calloc(devices_len, sizeof(*devices));
if (devices == NULL) { if (devices == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;

View File

@ -230,7 +230,7 @@ static struct wlr_wl_buffer *create_wl_buffer(struct wlr_wl_backend *wl,
return NULL; return NULL;
} }
struct wlr_wl_buffer *buffer = calloc(1, sizeof(struct wlr_wl_buffer)); struct wlr_wl_buffer *buffer = calloc(1, sizeof(*buffer));
if (buffer == NULL) { if (buffer == NULL) {
wl_buffer_destroy(wl_buffer); wl_buffer_destroy(wl_buffer);
return NULL; return NULL;

View File

@ -448,7 +448,7 @@ void create_pointer(struct wlr_wl_seat *seat, struct wlr_wl_output *output) {
wlr_log(WLR_DEBUG, "creating pointer for output '%s' from seat '%s'", wlr_log(WLR_DEBUG, "creating pointer for output '%s' from seat '%s'",
output->wlr_output.name, seat->name); output->wlr_output.name, seat->name);
struct wlr_wl_pointer *pointer = calloc(1, sizeof(struct wlr_wl_pointer)); struct wlr_wl_pointer *pointer = calloc(1, sizeof(*pointer));
if (pointer == NULL) { if (pointer == NULL) {
wlr_log(WLR_ERROR, "failed to allocate wlr_wl_pointer"); wlr_log(WLR_ERROR, "failed to allocate wlr_wl_pointer");
return; return;

View File

@ -266,7 +266,7 @@ static const struct wl_seat_listener seat_listener;
bool create_wl_seat(struct wl_seat *wl_seat, struct wlr_wl_backend *wl, bool create_wl_seat(struct wl_seat *wl_seat, struct wlr_wl_backend *wl,
uint32_t global_name) { uint32_t global_name) {
struct wlr_wl_seat *seat = calloc(1, sizeof(struct wlr_wl_seat)); struct wlr_wl_seat *seat = calloc(1, sizeof(*seat));
if (!seat) { if (!seat) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return false; return false;

View File

@ -206,8 +206,7 @@ static void handle_tablet_pad_group_ring(void *data,
struct zwp_tablet_pad_group_v2 *pad_group, struct zwp_tablet_pad_group_v2 *pad_group,
struct zwp_tablet_pad_ring_v2 *ring) { struct zwp_tablet_pad_ring_v2 *ring) {
struct tablet_pad_group *group = data; struct tablet_pad_group *group = data;
struct tablet_pad_ring *tablet_ring = struct tablet_pad_ring *tablet_ring = calloc(1, sizeof(*tablet_ring));
calloc(1, sizeof(struct tablet_pad_ring));
if (!tablet_ring) { if (!tablet_ring) {
zwp_tablet_pad_ring_v2_destroy(ring); zwp_tablet_pad_ring_v2_destroy(ring);
return; return;
@ -227,8 +226,7 @@ static void handle_tablet_pad_group_strip(void *data,
struct zwp_tablet_pad_group_v2 *pad_group, struct zwp_tablet_pad_group_v2 *pad_group,
struct zwp_tablet_pad_strip_v2 *strip) { struct zwp_tablet_pad_strip_v2 *strip) {
struct tablet_pad_group *group = data; struct tablet_pad_group *group = data;
struct tablet_pad_strip *tablet_strip = struct tablet_pad_strip *tablet_strip = calloc(1, sizeof(*tablet_strip));
calloc(1, sizeof(struct tablet_pad_strip));
if (!tablet_strip) { if (!tablet_strip) {
zwp_tablet_pad_strip_v2_destroy(strip); zwp_tablet_pad_strip_v2_destroy(strip);
return; return;
@ -296,8 +294,7 @@ static void handle_tablet_pad_group(void *data,
struct wlr_wl_seat *seat = data; struct wlr_wl_seat *seat = data;
struct wlr_tablet_pad *pad = &seat->wlr_tablet_pad; struct wlr_tablet_pad *pad = &seat->wlr_tablet_pad;
struct tablet_pad_group *group = struct tablet_pad_group *group = calloc(1, sizeof(*group));
calloc(1, sizeof(struct tablet_pad_group));
if (!group) { if (!group) {
wlr_log_errno(WLR_ERROR, "failed to allocate tablet_pad_group"); wlr_log_errno(WLR_ERROR, "failed to allocate tablet_pad_group");
zwp_tablet_pad_group_v2_destroy(pad_group); zwp_tablet_pad_group_v2_destroy(pad_group);
@ -788,7 +785,7 @@ static void handle_tool_added(void *data,
wl_signal_init(&seat->wlr_tablet_tool.events.destroy); wl_signal_init(&seat->wlr_tablet_tool.events.destroy);
struct tablet_tool *tool = calloc(1, sizeof(struct tablet_tool)); struct tablet_tool *tool = calloc(1, sizeof(*tool));
if (tool == NULL) { if (tool == NULL) {
wlr_log_errno(WLR_ERROR, "failed to allocate tablet_tool"); wlr_log_errno(WLR_ERROR, "failed to allocate tablet_tool");
zwp_tablet_tool_v2_destroy(zwp_tablet_tool_v2); zwp_tablet_tool_v2_destroy(zwp_tablet_tool_v2);

View File

@ -232,7 +232,7 @@ void handle_x11_xinput_event(struct wlr_x11_backend *x11,
id = last_touchpoint->wayland_id + 1; id = last_touchpoint->wayland_id + 1;
} }
struct wlr_x11_touchpoint *touchpoint = calloc(1, sizeof(struct wlr_x11_touchpoint)); struct wlr_x11_touchpoint *touchpoint = calloc(1, sizeof(*touchpoint));
touchpoint->x11_id = ev->detail; touchpoint->x11_id = ev->detail;
touchpoint->wayland_id = id; touchpoint->wayland_id = id;
wl_list_init(&touchpoint->link); wl_list_init(&touchpoint->link);

View File

@ -256,7 +256,7 @@ static struct wlr_x11_buffer *create_x11_buffer(struct wlr_x11_output *output,
return NULL; return NULL;
} }
struct wlr_x11_buffer *buffer = calloc(1, sizeof(struct wlr_x11_buffer)); struct wlr_x11_buffer *buffer = calloc(1, sizeof(*buffer));
if (!buffer) { if (!buffer) {
xcb_free_pixmap(x11->xcb, pixmap); xcb_free_pixmap(x11->xcb, pixmap);
return NULL; return NULL;
@ -535,7 +535,7 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
return NULL; return NULL;
} }
struct wlr_x11_output *output = calloc(1, sizeof(struct wlr_x11_output)); struct wlr_x11_output *output = calloc(1, sizeof(*output));
if (output == NULL) { if (output == NULL) {
return NULL; return NULL;
} }

View File

@ -101,7 +101,7 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
wlr_output_init_render(wlr_output, server->allocator, server->renderer); wlr_output_init_render(wlr_output, server->allocator, server->renderer);
struct output *output = calloc(1, sizeof(struct output)); struct output *output = calloc(1, sizeof(*output));
output->wlr = wlr_output; output->wlr = wlr_output;
output->server = server; output->server = server;
output->frame.notify = output_handle_frame; output->frame.notify = output_handle_frame;

View File

@ -252,7 +252,7 @@ static const struct zwlr_foreign_toplevel_handle_v1_listener toplevel_impl = {
static void toplevel_manager_handle_toplevel(void *data, static void toplevel_manager_handle_toplevel(void *data,
struct zwlr_foreign_toplevel_manager_v1 *toplevel_manager, struct zwlr_foreign_toplevel_manager_v1 *toplevel_manager,
struct zwlr_foreign_toplevel_handle_v1 *zwlr_toplevel) { struct zwlr_foreign_toplevel_handle_v1 *zwlr_toplevel) {
struct toplevel_v1 *toplevel = calloc(1, sizeof(struct toplevel_v1)); struct toplevel_v1 *toplevel = calloc(1, sizeof(*toplevel));
if (!toplevel) { if (!toplevel) {
fprintf(stderr, "Failed to allocate memory for toplevel\n"); fprintf(stderr, "Failed to allocate memory for toplevel\n");
return; return;

View File

@ -154,8 +154,7 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
wlr_output_init_render(wlr_output, server->allocator, server->renderer); wlr_output_init_render(wlr_output, server->allocator, server->renderer);
struct fullscreen_output *output = struct fullscreen_output *output = calloc(1, sizeof(*output));
calloc(1, sizeof(struct fullscreen_output));
output->wlr_output = wlr_output; output->wlr_output = wlr_output;
output->server = server; output->server = server;
output->frame.notify = output_handle_frame; output->frame.notify = output_handle_frame;

View File

@ -87,7 +87,7 @@ static const struct zwlr_gamma_control_v1_listener gamma_control_listener = {
static void registry_handle_global(void *data, struct wl_registry *registry, static void registry_handle_global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version) { uint32_t name, const char *interface, uint32_t version) {
if (strcmp(interface, wl_output_interface.name) == 0) { if (strcmp(interface, wl_output_interface.name) == 0) {
struct output *output = calloc(1, sizeof(struct output)); struct output *output = calloc(1, sizeof(*output));
output->wl_output = wl_registry_bind(registry, name, output->wl_output = wl_registry_bind(registry, name,
&wl_output_interface, 1); &wl_output_interface, 1);
wl_list_insert(&outputs, &output->link); wl_list_insert(&outputs, &output->link);

View File

@ -168,7 +168,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer); wlr_output_init_render(output, sample->allocator, sample->renderer);
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output)); struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
wlr_output_layout_add_auto(sample->layout, output); wlr_output_layout_add_auto(sample->layout, output);
sample_output->output = output; sample_output->output = output;
sample_output->sample = sample; sample_output->sample = sample;
@ -236,7 +236,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, new_input); struct sample_state *sample = wl_container_of(listener, sample, new_input);
switch (device->type) { switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:; case WLR_INPUT_DEVICE_KEYBOARD:;
struct sample_keyboard *keyboard = calloc(1, sizeof(struct sample_keyboard)); struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device); keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->sample = sample; keyboard->sample = sample;
wl_signal_add(&device->events.destroy, &keyboard->destroy); wl_signal_add(&device->events.destroy, &keyboard->destroy);

View File

@ -49,7 +49,7 @@ static const struct zwlr_output_power_v1_listener output_power_listener = {
static void registry_handle_global(void *data, struct wl_registry *registry, static void registry_handle_global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version) { uint32_t name, const char *interface, uint32_t version) {
if (strcmp(interface, wl_output_interface.name) == 0) { if (strcmp(interface, wl_output_interface.name) == 0) {
struct output *output = calloc(1, sizeof(struct output)); struct output *output = calloc(1, sizeof(*output));
output->wl_output = wl_registry_bind(registry, name, output->wl_output = wl_registry_bind(registry, name,
&wl_output_interface, 1); &wl_output_interface, 1);
wl_list_insert(&outputs, &output->link); wl_list_insert(&outputs, &output->link);

View File

@ -194,7 +194,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
static void handle_touch_down(struct wl_listener *listener, void *data) { static void handle_touch_down(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, touch_down); struct sample_state *sample = wl_container_of(listener, sample, touch_down);
struct wlr_touch_down_event *event = data; struct wlr_touch_down_event *event = data;
struct touch_point *point = calloc(1, sizeof(struct touch_point)); struct touch_point *point = calloc(1, sizeof(*point));
point->touch_id = event->touch_id; point->touch_id = event->touch_id;
point->x = event->x; point->x = event->x;
point->y = event->y; point->y = event->y;
@ -266,7 +266,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer); wlr_output_init_render(output, sample->allocator, sample->renderer);
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output)); struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
sample_output->output = output; sample_output->output = output;
sample_output->state = sample; sample_output->state = sample;
wl_signal_add(&output->events.frame, &sample_output->frame); wl_signal_add(&output->events.frame, &sample_output->frame);
@ -305,7 +305,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
break; break;
case WLR_INPUT_DEVICE_KEYBOARD:; case WLR_INPUT_DEVICE_KEYBOARD:;
struct sample_keyboard *keyboard = calloc(1, sizeof(struct sample_keyboard)); struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device); keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->state = state; keyboard->state = state;
wl_signal_add(&device->events.destroy, &keyboard->destroy); wl_signal_add(&device->events.destroy, &keyboard->destroy);

View File

@ -437,7 +437,7 @@ int main(int argc, char **argv) {
/* Initialize EGL context */ /* Initialize EGL context */
struct egl_info *e = calloc(1, sizeof(struct egl_info)); struct egl_info *e = calloc(1, sizeof(*e));
e->width = e->height = 512; e->width = e->height = 512;
egl_init(display); egl_init(display);
@ -465,7 +465,7 @@ int main(int argc, char **argv) {
/* Setup global state and render */ /* Setup global state and render */
struct window *w = calloc(1, sizeof(struct window)); struct window *w = calloc(1, sizeof(*w));
w->egl_info = e; w->egl_info = e;
draw_init(e); draw_init(e);

View File

@ -119,7 +119,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer); wlr_output_init_render(output, sample->allocator, sample->renderer);
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output)); struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
sample_output->x_offs = sample_output->y_offs = 0; sample_output->x_offs = sample_output->y_offs = 0;
sample_output->x_vel = sample_output->y_vel = 128; sample_output->x_vel = sample_output->y_vel = 128;
@ -187,7 +187,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, new_input); struct sample_state *sample = wl_container_of(listener, sample, new_input);
switch (device->type) { switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:; case WLR_INPUT_DEVICE_KEYBOARD:;
struct sample_keyboard *keyboard = calloc(1, sizeof(struct sample_keyboard)); struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device); keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->sample = sample; keyboard->sample = sample;
wl_signal_add(&device->events.destroy, &keyboard->destroy); wl_signal_add(&device->events.destroy, &keyboard->destroy);

View File

@ -72,8 +72,7 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
wlr_output_init_render(wlr_output, server->allocator, server->renderer); wlr_output_init_render(wlr_output, server->allocator, server->renderer);
struct output *output = struct output *output = calloc(1, sizeof(*output));
calloc(1, sizeof(struct output));
output->wlr = wlr_output; output->wlr = wlr_output;
output->server = server; output->server = server;
output->frame.notify = output_handle_frame; output->frame.notify = output_handle_frame;
@ -118,7 +117,7 @@ static void server_handle_new_surface(struct wl_listener *listener,
int pos = server->surface_offset; int pos = server->surface_offset;
server->surface_offset += 50; server->surface_offset += 50;
struct surface *surface = calloc(1, sizeof(struct surface)); struct surface *surface = calloc(1, sizeof(*surface));
surface->wlr = wlr_surface; surface->wlr = wlr_surface;
surface->commit.notify = surface_handle_commit; surface->commit.notify = surface_handle_commit;
wl_signal_add(&wlr_surface->events.commit, &surface->commit); wl_signal_add(&wlr_surface->events.commit, &surface->commit);

View File

@ -97,8 +97,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer); wlr_output_init_render(output, sample->allocator, sample->renderer);
struct sample_output *sample_output = struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
calloc(1, sizeof(struct sample_output));
sample_output->output = output; sample_output->output = output;
sample_output->sample = sample; sample_output->sample = sample;
wl_signal_add(&output->events.frame, &sample_output->frame); wl_signal_add(&output->events.frame, &sample_output->frame);
@ -146,8 +145,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, new_input); struct sample_state *sample = wl_container_of(listener, sample, new_input);
switch (device->type) { switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:; case WLR_INPUT_DEVICE_KEYBOARD:;
struct sample_keyboard *keyboard = struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
calloc(1, sizeof(struct sample_keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device); keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->sample = sample; keyboard->sample = sample;
wl_signal_add(&device->events.destroy, &keyboard->destroy); wl_signal_add(&device->events.destroy, &keyboard->destroy);

View File

@ -270,7 +270,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer); wlr_output_init_render(output, sample->allocator, sample->renderer);
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output)); struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
sample_output->output = output; sample_output->output = output;
sample_output->sample = sample; sample_output->sample = sample;
wl_signal_add(&output->events.frame, &sample_output->frame); wl_signal_add(&output->events.frame, &sample_output->frame);
@ -317,7 +317,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, new_input); struct sample_state *sample = wl_container_of(listener, sample, new_input);
switch (device->type) { switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:; case WLR_INPUT_DEVICE_KEYBOARD:;
struct sample_keyboard *keyboard = calloc(1, sizeof(struct sample_keyboard)); struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device); keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->sample = sample; keyboard->sample = sample;
wl_signal_add(&device->events.destroy, &keyboard->destroy); wl_signal_add(&device->events.destroy, &keyboard->destroy);
@ -340,7 +340,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
xkb_context_unref(context); xkb_context_unref(context);
break; break;
case WLR_INPUT_DEVICE_TABLET_PAD:; case WLR_INPUT_DEVICE_TABLET_PAD:;
struct tablet_pad_state *pstate = calloc(sizeof(struct tablet_pad_state), 1); struct tablet_pad_state *pstate = calloc(1, sizeof(*pstate));
pstate->wlr_tablet_pad = wlr_tablet_pad_from_input_device(device); pstate->wlr_tablet_pad = wlr_tablet_pad_from_input_device(device);
pstate->sample = sample; pstate->sample = sample;
pstate->destroy.notify = tablet_pad_destroy_notify; pstate->destroy.notify = tablet_pad_destroy_notify;
@ -358,7 +358,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
sample->height_mm = tablet->height_mm == 0 ? sample->height_mm = tablet->height_mm == 0 ?
10 : tablet->height_mm; 10 : tablet->height_mm;
struct tablet_tool_state *tstate = calloc(sizeof(struct tablet_tool_state), 1); struct tablet_tool_state *tstate = calloc(1, sizeof(*tstate));
tstate->wlr_tablet = tablet; tstate->wlr_tablet = tablet;
tstate->sample = sample; tstate->sample = sample;
tstate->destroy.notify = tablet_tool_destroy_notify; tstate->destroy.notify = tablet_tool_destroy_notify;

View File

@ -121,7 +121,7 @@ static void show_status(void) {
for (unsigned i = 0; i < utf8_strlen(buffer); i++) { for (unsigned i = 0; i < utf8_strlen(buffer); i++) {
printf(" "); printf(" ");
} }
char *cursor_mark = calloc(utf8_strlen(preedit_text) + 2, sizeof(char)); char *cursor_mark = calloc(utf8_strlen(preedit_text) + 2, sizeof(*cursor_mark));
for (unsigned i = 0; i < utf8_strlen(preedit_text); i++) { for (unsigned i = 0; i < utf8_strlen(preedit_text); i++) {
cursor_mark[i] = '.'; cursor_mark[i] = '.';
} }
@ -249,7 +249,7 @@ static void text_input_handle_done(void *data,
commit_string = ""; commit_string = "";
} }
size_t new_size = strlen(buffer) + strlen(commit_string) + 1; size_t new_size = strlen(buffer) + strlen(commit_string) + 1;
char *new_buffer = calloc(new_size, sizeof(char)); // realloc may fail anyway char *new_buffer = calloc(new_size, sizeof(*new_buffer)); // realloc may fail anyway
snprintf(new_buffer, new_size, "%s%s", buffer, commit_string); snprintf(new_buffer, new_size, "%s%s", buffer, commit_string);
free(buffer); free(buffer);
buffer = new_buffer; buffer = new_buffer;
@ -333,7 +333,7 @@ int main(int argc, char **argv) {
} }
} }
buffer = calloc(1, sizeof(char)); buffer = calloc(1, sizeof(*buffer));
display = wl_display_connect(NULL); display = wl_display_connect(NULL);
if (display == NULL) { if (display == NULL) {

View File

@ -104,7 +104,7 @@ static void touch_down_notify(struct wl_listener *listener, void *data) {
struct wlr_touch_down_event *event = data; struct wlr_touch_down_event *event = data;
struct touch_state *tstate = wl_container_of(listener, tstate, down); struct touch_state *tstate = wl_container_of(listener, tstate, down);
struct sample_state *sample = tstate->sample; struct sample_state *sample = tstate->sample;
struct touch_point *point = calloc(1, sizeof(struct touch_point)); struct touch_point *point = calloc(1, sizeof(*point));
point->touch_id = event->touch_id; point->touch_id = event->touch_id;
point->x = event->x; point->x = event->x;
point->y = event->y; point->y = event->y;
@ -175,7 +175,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer); wlr_output_init_render(output, sample->allocator, sample->renderer);
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output)); struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
sample_output->output = output; sample_output->output = output;
sample_output->sample = sample; sample_output->sample = sample;
wl_signal_add(&output->events.frame, &sample_output->frame); wl_signal_add(&output->events.frame, &sample_output->frame);
@ -222,7 +222,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, new_input); struct sample_state *sample = wl_container_of(listener, sample, new_input);
switch (device->type) { switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:; case WLR_INPUT_DEVICE_KEYBOARD:;
struct sample_keyboard *keyboard = calloc(1, sizeof(struct sample_keyboard)); struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device); keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->sample = sample; keyboard->sample = sample;
wl_signal_add(&device->events.destroy, &keyboard->destroy); wl_signal_add(&device->events.destroy, &keyboard->destroy);
@ -245,7 +245,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
xkb_context_unref(context); xkb_context_unref(context);
break; break;
case WLR_INPUT_DEVICE_TOUCH:; case WLR_INPUT_DEVICE_TOUCH:;
struct touch_state *tstate = calloc(sizeof(struct touch_state), 1); struct touch_state *tstate = calloc(1, sizeof(*tstate));
tstate->wlr_touch = wlr_touch_from_input_device(device); tstate->wlr_touch = wlr_touch_from_input_device(device);
tstate->sample = sample; tstate->sample = sample;
tstate->destroy.notify = touch_destroy_notify; tstate->destroy.notify = touch_destroy_notify;

View File

@ -210,7 +210,7 @@ static struct wlr_egl *egl_create(void) {
return NULL; return NULL;
} }
struct wlr_egl *egl = calloc(1, sizeof(struct wlr_egl)); struct wlr_egl *egl = calloc(1, sizeof(*egl));
if (egl == NULL) { if (egl == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;
@ -457,7 +457,7 @@ static EGLDeviceEXT get_egl_device_from_drm_fd(struct wlr_egl *egl,
return EGL_NO_DEVICE_EXT; return EGL_NO_DEVICE_EXT;
} }
EGLDeviceEXT *devices = calloc(nb_devices, sizeof(EGLDeviceEXT)); EGLDeviceEXT *devices = calloc(nb_devices, sizeof(*devices));
if (devices == NULL) { if (devices == NULL) {
wlr_log_errno(WLR_ERROR, "Failed to allocate EGL device list"); wlr_log_errno(WLR_ERROR, "Failed to allocate EGL device list");
return EGL_NO_DEVICE_EXT; return EGL_NO_DEVICE_EXT;
@ -807,7 +807,7 @@ static int get_egl_dmabuf_formats(struct wlr_egl *egl, EGLint **formats) {
}; };
int num = sizeof(fallback_formats) / sizeof(fallback_formats[0]); int num = sizeof(fallback_formats) / sizeof(fallback_formats[0]);
*formats = calloc(num, sizeof(EGLint)); *formats = calloc(num, sizeof(**formats));
if (!*formats) { if (!*formats) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return -1; return -1;
@ -823,7 +823,7 @@ static int get_egl_dmabuf_formats(struct wlr_egl *egl, EGLint **formats) {
return -1; return -1;
} }
*formats = calloc(num, sizeof(EGLint)); *formats = calloc(num, sizeof(**formats));
if (*formats == NULL) { if (*formats == NULL) {
wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno)); wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno));
return -1; return -1;
@ -860,12 +860,12 @@ static int get_egl_dmabuf_modifiers(struct wlr_egl *egl, EGLint format,
return 0; return 0;
} }
*modifiers = calloc(num, sizeof(uint64_t)); *modifiers = calloc(num, sizeof(**modifiers));
if (*modifiers == NULL) { if (*modifiers == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return -1; return -1;
} }
*external_only = calloc(num, sizeof(EGLBoolean)); *external_only = calloc(num, sizeof(**external_only));
if (*external_only == NULL) { if (*external_only == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
free(*modifiers); free(*modifiers);
@ -912,7 +912,7 @@ static char *get_render_name(const char *name) {
wlr_log(WLR_ERROR, "drmGetDevices2 failed: %s", strerror(-devices_len)); wlr_log(WLR_ERROR, "drmGetDevices2 failed: %s", strerror(-devices_len));
return NULL; return NULL;
} }
drmDevice **devices = calloc(devices_len, sizeof(drmDevice *)); drmDevice **devices = calloc(devices_len, sizeof(*devices));
if (devices == NULL) { if (devices == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;

View File

@ -583,7 +583,7 @@ static struct wlr_render_timer *gles2_render_timer_create(struct wlr_renderer *w
return NULL; return NULL;
} }
struct wlr_gles2_render_timer *timer = calloc(1, sizeof(struct wlr_gles2_render_timer)); struct wlr_gles2_render_timer *timer = calloc(1, sizeof(*timer));
if (!timer) { if (!timer) {
return NULL; return NULL;
} }
@ -826,8 +826,7 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) {
return NULL; return NULL;
} }
struct wlr_gles2_renderer *renderer = struct wlr_gles2_renderer *renderer = calloc(1, sizeof(*renderer));
calloc(1, sizeof(struct wlr_gles2_renderer));
if (renderer == NULL) { if (renderer == NULL) {
return NULL; return NULL;
} }

View File

@ -174,8 +174,7 @@ static const struct wlr_texture_impl texture_impl = {
static struct wlr_gles2_texture *gles2_texture_create( static struct wlr_gles2_texture *gles2_texture_create(
struct wlr_gles2_renderer *renderer, uint32_t width, uint32_t height) { struct wlr_gles2_renderer *renderer, uint32_t width, uint32_t height) {
struct wlr_gles2_texture *texture = struct wlr_gles2_texture *texture = calloc(1, sizeof(*texture));
calloc(1, sizeof(struct wlr_gles2_texture));
if (texture == NULL) { if (texture == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;

View File

@ -341,8 +341,7 @@ static const struct wlr_drm_format_set *pixman_get_render_formats(
static struct wlr_pixman_texture *pixman_texture_create( static struct wlr_pixman_texture *pixman_texture_create(
struct wlr_pixman_renderer *renderer, uint32_t drm_format, struct wlr_pixman_renderer *renderer, uint32_t drm_format,
uint32_t width, uint32_t height) { uint32_t width, uint32_t height) {
struct wlr_pixman_texture *texture = struct wlr_pixman_texture *texture = calloc(1, sizeof(*texture));
calloc(1, sizeof(struct wlr_pixman_texture));
if (texture == NULL) { if (texture == NULL) {
wlr_log_errno(WLR_ERROR, "Failed to allocate pixman texture"); wlr_log_errno(WLR_ERROR, "Failed to allocate pixman texture");
return NULL; return NULL;
@ -530,8 +529,7 @@ static const struct wlr_renderer_impl renderer_impl = {
}; };
struct wlr_renderer *wlr_pixman_renderer_create(void) { struct wlr_renderer *wlr_pixman_renderer_create(void) {
struct wlr_pixman_renderer *renderer = struct wlr_pixman_renderer *renderer = calloc(1, sizeof(*renderer));
calloc(1, sizeof(struct wlr_pixman_renderer));
if (renderer == NULL) { if (renderer == NULL) {
return NULL; return NULL;
} }

View File

@ -118,9 +118,9 @@ static bool render_pass_submit(struct wlr_render_pass *wlr_pass) {
// insert acquire and release barriers for dmabuf-images // insert acquire and release barriers for dmabuf-images
uint32_t barrier_count = wl_list_length(&renderer->foreign_textures) + 1; uint32_t barrier_count = wl_list_length(&renderer->foreign_textures) + 1;
VkImageMemoryBarrier *acquire_barriers = calloc(barrier_count, sizeof(VkImageMemoryBarrier)); VkImageMemoryBarrier *acquire_barriers = calloc(barrier_count, sizeof(*acquire_barriers));
VkImageMemoryBarrier *release_barriers = calloc(barrier_count, sizeof(VkImageMemoryBarrier)); VkImageMemoryBarrier *release_barriers = calloc(barrier_count, sizeof(*release_barriers));
render_wait = calloc(barrier_count * WLR_DMABUF_MAX_PLANES, sizeof(VkSemaphoreSubmitInfoKHR)); render_wait = calloc(barrier_count * WLR_DMABUF_MAX_PLANES, sizeof(*render_wait));
if (acquire_barriers == NULL || release_barriers == NULL || render_wait == NULL) { if (acquire_barriers == NULL || release_barriers == NULL || render_wait == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
free(acquire_barriers); free(acquire_barriers);

View File

@ -1117,9 +1117,9 @@ static void vulkan_end(struct wlr_renderer *wlr_renderer) {
// insert acquire and release barriers for dmabuf-images // insert acquire and release barriers for dmabuf-images
unsigned barrier_count = wl_list_length(&renderer->foreign_textures) + 1; unsigned barrier_count = wl_list_length(&renderer->foreign_textures) + 1;
VkImageMemoryBarrier *acquire_barriers = calloc(barrier_count, sizeof(VkImageMemoryBarrier)); VkImageMemoryBarrier *acquire_barriers = calloc(barrier_count, sizeof(*acquire_barriers));
VkImageMemoryBarrier *release_barriers = calloc(barrier_count, sizeof(VkImageMemoryBarrier)); VkImageMemoryBarrier *release_barriers = calloc(barrier_count, sizeof(*release_barriers));
VkSemaphoreSubmitInfoKHR *render_wait = calloc(barrier_count * WLR_DMABUF_MAX_PLANES, sizeof(VkSemaphoreSubmitInfoKHR)); VkSemaphoreSubmitInfoKHR *render_wait = calloc(barrier_count * WLR_DMABUF_MAX_PLANES, sizeof(*render_wait));
if (acquire_barriers == NULL || release_barriers == NULL || render_wait == NULL) { if (acquire_barriers == NULL || release_barriers == NULL || render_wait == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
free(acquire_barriers); free(acquire_barriers);

View File

@ -256,8 +256,7 @@ static const struct wlr_texture_impl texture_impl = {
static struct wlr_vk_texture *vulkan_texture_create( static struct wlr_vk_texture *vulkan_texture_create(
struct wlr_vk_renderer *renderer, uint32_t width, uint32_t height) { struct wlr_vk_renderer *renderer, uint32_t width, uint32_t height) {
struct wlr_vk_texture *texture = struct wlr_vk_texture *texture = calloc(1, sizeof(*texture));
calloc(1, sizeof(struct wlr_vk_texture));
if (texture == NULL) { if (texture == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;

View File

@ -252,7 +252,7 @@ static int open_drm_render_node(void) {
wlr_log(WLR_ERROR, "drmGetDevices2 failed: %s", strerror(-devices_len)); wlr_log(WLR_ERROR, "drmGetDevices2 failed: %s", strerror(-devices_len));
return -1; return -1;
} }
drmDevice **devices = calloc(devices_len, sizeof(drmDevice *)); drmDevice **devices = calloc(devices_len, sizeof(*devices));
if (devices == NULL) { if (devices == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return -1; return -1;

View File

@ -243,8 +243,7 @@ static void server_new_keyboard(struct tinywl_server *server,
struct wlr_input_device *device) { struct wlr_input_device *device) {
struct wlr_keyboard *wlr_keyboard = wlr_keyboard_from_input_device(device); struct wlr_keyboard *wlr_keyboard = wlr_keyboard_from_input_device(device);
struct tinywl_keyboard *keyboard = struct tinywl_keyboard *keyboard = calloc(1, sizeof(*keyboard));
calloc(1, sizeof(struct tinywl_keyboard));
keyboard->server = server; keyboard->server = server;
keyboard->wlr_keyboard = wlr_keyboard; keyboard->wlr_keyboard = wlr_keyboard;
@ -619,8 +618,7 @@ static void server_new_output(struct wl_listener *listener, void *data) {
wlr_output_state_finish(&state); wlr_output_state_finish(&state);
/* Allocates and configures our state for this output */ /* Allocates and configures our state for this output */
struct tinywl_output *output = struct tinywl_output *output = calloc(1, sizeof(*output));
calloc(1, sizeof(struct tinywl_output));
output->wlr_output = wlr_output; output->wlr_output = wlr_output;
output->server = server; output->server = server;
@ -794,8 +792,7 @@ static void server_new_xdg_surface(struct wl_listener *listener, void *data) {
assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
/* Allocate a tinywl_view for this surface */ /* Allocate a tinywl_view for this surface */
struct tinywl_view *view = struct tinywl_view *view = calloc(1, sizeof(*view));
calloc(1, sizeof(struct tinywl_view));
view->server = server; view->server = server;
view->xdg_toplevel = xdg_surface->toplevel; view->xdg_toplevel = xdg_surface->toplevel;
view->scene_tree = wlr_scene_xdg_surface_create( view->scene_tree = wlr_scene_xdg_surface_create(

View File

@ -62,8 +62,7 @@ struct wlr_client_buffer *wlr_client_buffer_create(struct wlr_buffer *buffer,
return NULL; return NULL;
} }
struct wlr_client_buffer *client_buffer = struct wlr_client_buffer *client_buffer = calloc(1, sizeof(*client_buffer));
calloc(1, sizeof(struct wlr_client_buffer));
if (client_buffer == NULL) { if (client_buffer == NULL) {
wlr_texture_destroy(texture); wlr_texture_destroy(texture);
return NULL; return NULL;

View File

@ -291,8 +291,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_data_device_manager *wlr_data_device_manager_create( struct wlr_data_device_manager *wlr_data_device_manager_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_data_device_manager *manager = struct wlr_data_device_manager *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_data_device_manager));
if (manager == NULL) { if (manager == NULL) {
wlr_log(WLR_ERROR, "could not create data device manager"); wlr_log(WLR_ERROR, "could not create data device manager");
return NULL; return NULL;

View File

@ -242,7 +242,7 @@ struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource,
assert(seat_client != NULL); assert(seat_client != NULL);
assert(source != NULL); // a NULL source means no selection assert(source != NULL); // a NULL source means no selection
struct wlr_data_offer *offer = calloc(1, sizeof(struct wlr_data_offer)); struct wlr_data_offer *offer = calloc(1, sizeof(*offer));
if (offer == NULL) { if (offer == NULL) {
return NULL; return NULL;
} }

View File

@ -235,8 +235,7 @@ static void data_source_handle_resource_destroy(struct wl_resource *resource) {
struct wlr_client_data_source *client_data_source_create( struct wlr_client_data_source *client_data_source_create(
struct wl_client *client, uint32_t version, uint32_t id, struct wl_client *client, uint32_t version, uint32_t id,
struct wl_list *resource_list) { struct wl_list *resource_list) {
struct wlr_client_data_source *source = struct wlr_client_data_source *source = calloc(1, sizeof(*source));
calloc(1, sizeof(struct wlr_client_data_source));
if (source == NULL) { if (source == NULL) {
return NULL; return NULL;
} }

View File

@ -378,7 +378,7 @@ static void drag_icon_handle_surface_destroy(struct wl_listener *listener,
static struct wlr_drag_icon *drag_icon_create(struct wlr_drag *drag, static struct wlr_drag_icon *drag_icon_create(struct wlr_drag *drag,
struct wlr_surface *surface) { struct wlr_surface *surface) {
struct wlr_drag_icon *icon = calloc(1, sizeof(struct wlr_drag_icon)); struct wlr_drag_icon *icon = calloc(1, sizeof(*icon));
if (!icon) { if (!icon) {
return NULL; return NULL;
} }
@ -398,7 +398,7 @@ static struct wlr_drag_icon *drag_icon_create(struct wlr_drag *drag,
struct wlr_drag *wlr_drag_create(struct wlr_seat_client *seat_client, struct wlr_drag *wlr_drag_create(struct wlr_seat_client *seat_client,
struct wlr_data_source *source, struct wlr_surface *icon_surface) { struct wlr_data_source *source, struct wlr_surface *icon_surface) {
struct wlr_drag *drag = calloc(1, sizeof(struct wlr_drag)); struct wlr_drag *drag = calloc(1, sizeof(*drag));
if (drag == NULL) { if (drag == NULL) {
return NULL; return NULL;
} }

View File

@ -495,8 +495,7 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
} }
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) { struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) {
struct wlr_output_cursor *cursor = struct wlr_output_cursor *cursor = calloc(1, sizeof(*cursor));
calloc(1, sizeof(struct wlr_output_cursor));
if (cursor == NULL) { if (cursor == NULL) {
return NULL; return NULL;
} }

View File

@ -149,7 +149,7 @@ static void scene_tree_init(struct wlr_scene_tree *tree,
} }
struct wlr_scene *wlr_scene_create(void) { struct wlr_scene *wlr_scene_create(void) {
struct wlr_scene *scene = calloc(1, sizeof(struct wlr_scene)); struct wlr_scene *scene = calloc(1, sizeof(*scene));
if (scene == NULL) { if (scene == NULL) {
return NULL; return NULL;
} }
@ -177,7 +177,7 @@ struct wlr_scene *wlr_scene_create(void) {
struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_tree *parent) { struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_tree *parent) {
assert(parent); assert(parent);
struct wlr_scene_tree *tree = calloc(1, sizeof(struct wlr_scene_tree)); struct wlr_scene_tree *tree = calloc(1, sizeof(*tree));
if (tree == NULL) { if (tree == NULL) {
return NULL; return NULL;
} }
@ -564,8 +564,7 @@ static void scene_node_update(struct wlr_scene_node *node,
struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_tree *parent, struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_tree *parent,
int width, int height, const float color[static 4]) { int width, int height, const float color[static 4]) {
struct wlr_scene_rect *scene_rect = struct wlr_scene_rect *scene_rect = calloc(1, sizeof(*scene_rect));
calloc(1, sizeof(struct wlr_scene_rect));
if (scene_rect == NULL) { if (scene_rect == NULL) {
return NULL; return NULL;
} }
@ -1727,8 +1726,7 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output,
// add the current frame's damage if there is damage // add the current frame's damage if there is damage
if (pixman_region32_not_empty(&scene_output->damage_ring.current)) { if (pixman_region32_not_empty(&scene_output->damage_ring.current)) {
struct highlight_region *current_damage = struct highlight_region *current_damage = calloc(1, sizeof(*current_damage));
calloc(1, sizeof(*current_damage));
if (current_damage) { if (current_damage) {
pixman_region32_init(&current_damage->region); pixman_region32_init(&current_damage->region);
pixman_region32_copy(&current_damage->region, pixman_region32_copy(&current_damage->region,

View File

@ -140,8 +140,7 @@ static const struct wl_seat_interface seat_impl = {
static struct wlr_seat_client *seat_client_create(struct wlr_seat *wlr_seat, static struct wlr_seat_client *seat_client_create(struct wlr_seat *wlr_seat,
struct wl_client *client, struct wl_resource *wl_resource) { struct wl_client *client, struct wl_resource *wl_resource) {
struct wlr_seat_client *seat_client = struct wlr_seat_client *seat_client = calloc(1, sizeof(*seat_client));
calloc(1, sizeof(struct wlr_seat_client));
if (!seat_client) { if (!seat_client) {
return NULL; return NULL;
} }
@ -255,7 +254,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
} }
struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) { struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
struct wlr_seat *seat = calloc(1, sizeof(struct wlr_seat)); struct wlr_seat *seat = calloc(1, sizeof(*seat));
if (!seat) { if (!seat) {
return NULL; return NULL;
} }
@ -264,8 +263,7 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
seat->pointer_state.seat = seat; seat->pointer_state.seat = seat;
wl_list_init(&seat->pointer_state.surface_destroy.link); wl_list_init(&seat->pointer_state.surface_destroy.link);
struct wlr_seat_pointer_grab *pointer_grab = struct wlr_seat_pointer_grab *pointer_grab = calloc(1, sizeof(*pointer_grab));
calloc(1, sizeof(struct wlr_seat_pointer_grab));
if (!pointer_grab) { if (!pointer_grab) {
free(seat); free(seat);
return NULL; return NULL;
@ -278,8 +276,7 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
wl_signal_init(&seat->pointer_state.events.focus_change); wl_signal_init(&seat->pointer_state.events.focus_change);
// keyboard state // keyboard state
struct wlr_seat_keyboard_grab *keyboard_grab = struct wlr_seat_keyboard_grab *keyboard_grab = calloc(1, sizeof(*keyboard_grab));
calloc(1, sizeof(struct wlr_seat_keyboard_grab));
if (!keyboard_grab) { if (!keyboard_grab) {
free(pointer_grab); free(pointer_grab);
free(seat); free(seat);
@ -296,8 +293,7 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
wl_signal_init(&seat->keyboard_state.events.focus_change); wl_signal_init(&seat->keyboard_state.events.focus_change);
// touch state // touch state
struct wlr_seat_touch_grab *touch_grab = struct wlr_seat_touch_grab *touch_grab = calloc(1, sizeof(*touch_grab));
calloc(1, sizeof(struct wlr_seat_touch_grab));
if (!touch_grab) { if (!touch_grab) {
free(pointer_grab); free(pointer_grab);
free(keyboard_grab); free(keyboard_grab);

View File

@ -144,7 +144,7 @@ static struct wlr_touch_point *touch_point_create(
return NULL; return NULL;
} }
struct wlr_touch_point *point = calloc(1, sizeof(struct wlr_touch_point)); struct wlr_touch_point *point = calloc(1, sizeof(*point));
if (!point) { if (!point) {
return NULL; return NULL;
} }

View File

@ -45,8 +45,7 @@ static void handle_wlr_seat_destroy(struct wl_listener *listener, void *data) {
static struct wlr_tablet_seat_v2 *create_tablet_seat( static struct wlr_tablet_seat_v2 *create_tablet_seat(
struct wlr_tablet_manager_v2 *manager, struct wlr_tablet_manager_v2 *manager,
struct wlr_seat *wlr_seat) { struct wlr_seat *wlr_seat) {
struct wlr_tablet_seat_v2 *tablet_seat = struct wlr_tablet_seat_v2 *tablet_seat = calloc(1, sizeof(*tablet_seat));
calloc(1, sizeof(struct wlr_tablet_seat_v2));
if (!tablet_seat) { if (!tablet_seat) {
return NULL; return NULL;
} }
@ -175,8 +174,7 @@ static void get_tablet_seat(struct wl_client *wl_client, struct wl_resource *res
return; return;
} }
struct wlr_tablet_seat_client_v2 *seat_client = struct wlr_tablet_seat_client_v2 *seat_client = calloc(1, sizeof(*seat_client));
calloc(1, sizeof(struct wlr_tablet_seat_client_v2));
if (seat_client == NULL) { if (seat_client == NULL) {
wl_client_post_no_memory(wl_client); wl_client_post_no_memory(wl_client);
return; return;
@ -250,8 +248,7 @@ static void tablet_v2_bind(struct wl_client *wl_client, void *data,
struct wlr_tablet_manager_v2 *manager = data; struct wlr_tablet_manager_v2 *manager = data;
assert(wl_client && manager); assert(wl_client && manager);
struct wlr_tablet_manager_client_v2 *client = struct wlr_tablet_manager_client_v2 *client = calloc(1, sizeof(*client));
calloc(1, sizeof(struct wlr_tablet_manager_client_v2));
if (client == NULL) { if (client == NULL) {
wl_client_post_no_memory(wl_client); wl_client_post_no_memory(wl_client);
return; return;
@ -284,8 +281,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
} }
struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display) { struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display) {
struct wlr_tablet_manager_v2 *tablet = struct wlr_tablet_manager_v2 *tablet = calloc(1, sizeof(*tablet));
calloc(1, sizeof(struct wlr_tablet_manager_v2));
if (!tablet) { if (!tablet) {
return NULL; return NULL;
} }

View File

@ -200,8 +200,7 @@ static void add_tablet_pad_group(struct wlr_tablet_v2_tablet_pad *pad,
wl_client_post_no_memory(client->client); wl_client_post_no_memory(client->client);
return; return;
} }
struct tablet_pad_auxiliary_user_data *user_data = struct tablet_pad_auxiliary_user_data *user_data = calloc(1, sizeof(*user_data));
calloc(1, sizeof(struct tablet_pad_auxiliary_user_data));
if (!user_data) { if (!user_data) {
wl_client_post_no_memory(client->client); wl_client_post_no_memory(client->client);
return; return;
@ -224,8 +223,7 @@ static void add_tablet_pad_group(struct wlr_tablet_v2_tablet_pad *pad,
client->strip_count = group->strip_count; client->strip_count = group->strip_count;
for (size_t i = 0; i < group->strip_count; ++i) { for (size_t i = 0; i < group->strip_count; ++i) {
size_t strip = group->strips[i]; size_t strip = group->strips[i];
struct tablet_pad_auxiliary_user_data *user_data = struct tablet_pad_auxiliary_user_data *user_data = calloc(1, sizeof(*user_data));
calloc(1, sizeof(struct tablet_pad_auxiliary_user_data));
if (!user_data) { if (!user_data) {
wl_client_post_no_memory(client->client); wl_client_post_no_memory(client->client);
return; return;
@ -248,8 +246,7 @@ static void add_tablet_pad_group(struct wlr_tablet_v2_tablet_pad *pad,
client->ring_count = group->ring_count; client->ring_count = group->ring_count;
for (size_t i = 0; i < group->ring_count; ++i) { for (size_t i = 0; i < group->ring_count; ++i) {
size_t ring = group->rings[i]; size_t ring = group->rings[i];
struct tablet_pad_auxiliary_user_data *user_data = struct tablet_pad_auxiliary_user_data *user_data = calloc(1, sizeof(*user_data));
calloc(1, sizeof(struct tablet_pad_auxiliary_user_data));
if (!user_data) { if (!user_data) {
wl_client_post_no_memory(client->client); wl_client_post_no_memory(client->client);
return; return;
@ -274,8 +271,7 @@ static void add_tablet_pad_group(struct wlr_tablet_v2_tablet_pad *pad,
void add_tablet_pad_client(struct wlr_tablet_seat_client_v2 *seat, void add_tablet_pad_client(struct wlr_tablet_seat_client_v2 *seat,
struct wlr_tablet_v2_tablet_pad *pad) { struct wlr_tablet_v2_tablet_pad *pad) {
struct wlr_tablet_pad_client_v2 *client = struct wlr_tablet_pad_client_v2 *client = calloc(1, sizeof(*client));
calloc(1, sizeof(struct wlr_tablet_pad_client_v2));
if (!client) { if (!client) {
wl_client_post_no_memory(seat->wl_client); wl_client_post_no_memory(seat->wl_client);
return; return;
@ -283,14 +279,14 @@ void add_tablet_pad_client(struct wlr_tablet_seat_client_v2 *seat,
client->pad = pad; client->pad = pad;
client->seat = seat; client->seat = seat;
client->groups = calloc(wl_list_length(&pad->wlr_pad->groups), sizeof(struct wl_resource*)); client->groups = calloc(wl_list_length(&pad->wlr_pad->groups), sizeof(*client->groups));
if (!client->groups) { if (!client->groups) {
wl_client_post_no_memory(seat->wl_client); wl_client_post_no_memory(seat->wl_client);
free(client); free(client);
return; return;
} }
client->rings = calloc(pad->wlr_pad->ring_count, sizeof(struct wl_resource*)); client->rings = calloc(pad->wlr_pad->ring_count, sizeof(*client->rings));
if (!client->rings) { if (!client->rings) {
wl_client_post_no_memory(seat->wl_client); wl_client_post_no_memory(seat->wl_client);
free(client->groups); free(client->groups);
@ -298,7 +294,7 @@ void add_tablet_pad_client(struct wlr_tablet_seat_client_v2 *seat,
return; return;
} }
client->strips = calloc(pad->wlr_pad->strip_count, sizeof(struct wl_resource*)); client->strips = calloc(pad->wlr_pad->strip_count, sizeof(*client->strips));
if (!client->strips) { if (!client->strips) {
wl_client_post_no_memory(seat->wl_client); wl_client_post_no_memory(seat->wl_client);
free(client->groups); free(client->groups);
@ -376,7 +372,7 @@ struct wlr_tablet_v2_tablet_pad *wlr_tablet_pad_create(
return NULL; return NULL;
} }
struct wlr_tablet_pad *wlr_pad = wlr_tablet_pad_from_input_device(wlr_device); struct wlr_tablet_pad *wlr_pad = wlr_tablet_pad_from_input_device(wlr_device);
struct wlr_tablet_v2_tablet_pad *pad = calloc(1, sizeof(struct wlr_tablet_v2_tablet_pad)); struct wlr_tablet_v2_tablet_pad *pad = calloc(1, sizeof(*pad));
if (!pad) { if (!pad) {
return NULL; return NULL;
} }

View File

@ -61,7 +61,7 @@ struct wlr_tablet_v2_tablet *wlr_tablet_create(
return NULL; return NULL;
} }
struct wlr_tablet *wlr_tablet = wlr_tablet_from_input_device(wlr_device); struct wlr_tablet *wlr_tablet = wlr_tablet_from_input_device(wlr_device);
struct wlr_tablet_v2_tablet *tablet = calloc(1, sizeof(struct wlr_tablet_v2_tablet)); struct wlr_tablet_v2_tablet *tablet = calloc(1, sizeof(*tablet));
if (!tablet) { if (!tablet) {
return NULL; return NULL;
} }
@ -88,8 +88,7 @@ struct wlr_tablet_v2_tablet *wlr_tablet_create(
void add_tablet_client(struct wlr_tablet_seat_client_v2 *seat, void add_tablet_client(struct wlr_tablet_seat_client_v2 *seat,
struct wlr_tablet_v2_tablet *tablet) { struct wlr_tablet_v2_tablet *tablet) {
struct wlr_tablet_client_v2 *client = struct wlr_tablet_client_v2 *client = calloc(1, sizeof(*client));
calloc(1, sizeof(struct wlr_tablet_client_v2));
if (!client) { if (!client) {
return; return;
} }

View File

@ -119,8 +119,7 @@ void destroy_tablet_tool_v2(struct wl_resource *resource) {
void add_tablet_tool_client(struct wlr_tablet_seat_client_v2 *seat, void add_tablet_tool_client(struct wlr_tablet_seat_client_v2 *seat,
struct wlr_tablet_v2_tablet_tool *tool) { struct wlr_tablet_v2_tablet_tool *tool) {
struct wlr_tablet_tool_client_v2 *client = struct wlr_tablet_tool_client_v2 *client = calloc(1, sizeof(*client));
calloc(1, sizeof(struct wlr_tablet_tool_client_v2));
if (!client) { if (!client) {
return; return;
} }
@ -233,8 +232,7 @@ struct wlr_tablet_v2_tablet_tool *wlr_tablet_tool_create(
if (!seat) { if (!seat) {
return NULL; return NULL;
} }
struct wlr_tablet_v2_tablet_tool *tool = struct wlr_tablet_v2_tablet_tool *tool = calloc(1, sizeof(*tool));
calloc(1, sizeof(struct wlr_tablet_v2_tablet_tool));
if (!tool) { if (!tool) {
return NULL; return NULL;
} }
@ -822,15 +820,14 @@ void wlr_tablet_tool_v2_start_implicit_grab(
return; return;
} }
struct wlr_tablet_tool_v2_grab *grab = struct wlr_tablet_tool_v2_grab *grab = calloc(1, sizeof(*grab));
calloc(1, sizeof(struct wlr_tablet_tool_v2_grab));
if (!grab) { if (!grab) {
return; return;
} }
grab->interface = &implicit_tool_grab_interface; grab->interface = &implicit_tool_grab_interface;
grab->tool = tool; grab->tool = tool;
struct implicit_grab_state *state = calloc(1, sizeof(struct implicit_grab_state)); struct implicit_grab_state *state = calloc(1, sizeof(*state));
if (!state) { if (!state) {
free(grab); free(grab);
return; return;

View File

@ -671,7 +671,7 @@ static void surface_handle_renderer_destroy(struct wl_listener *listener,
static struct wlr_surface *surface_create(struct wl_client *client, static struct wlr_surface *surface_create(struct wl_client *client,
uint32_t version, uint32_t id, struct wlr_renderer *renderer) { uint32_t version, uint32_t id, struct wlr_renderer *renderer) {
struct wlr_surface *surface = calloc(1, sizeof(struct wlr_surface)); struct wlr_surface *surface = calloc(1, sizeof(*surface));
if (!surface) { if (!surface) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return NULL; return NULL;
@ -970,7 +970,7 @@ void wlr_surface_send_enter(struct wlr_surface *surface,
} }
} }
surface_output = calloc(1, sizeof(struct wlr_surface_output)); surface_output = calloc(1, sizeof(*surface_output));
if (surface_output == NULL) { if (surface_output == NULL) {
return; return;
} }

View File

@ -104,7 +104,7 @@ struct wlr_cursor_state {
}; };
struct wlr_cursor *wlr_cursor_create(void) { struct wlr_cursor *wlr_cursor_create(void) {
struct wlr_cursor_state *state = calloc(1, sizeof(struct wlr_cursor_state)); struct wlr_cursor_state *state = calloc(1, sizeof(*state));
if (!state) { if (!state) {
wlr_log(WLR_ERROR, "Failed to allocate wlr_cursor_state"); wlr_log(WLR_ERROR, "Failed to allocate wlr_cursor_state");
return NULL; return NULL;
@ -916,8 +916,7 @@ static void handle_device_destroy(struct wl_listener *listener, void *data) {
static struct wlr_cursor_device *cursor_device_create( static struct wlr_cursor_device *cursor_device_create(
struct wlr_cursor *cursor, struct wlr_input_device *device) { struct wlr_cursor *cursor, struct wlr_input_device *device) {
struct wlr_cursor_device *c_device = struct wlr_cursor_device *c_device = calloc(1, sizeof(*c_device));
calloc(1, sizeof(struct wlr_cursor_device));
if (!c_device) { if (!c_device) {
wlr_log(WLR_ERROR, "Failed to allocate wlr_cursor_device"); wlr_log(WLR_ERROR, "Failed to allocate wlr_cursor_device");
return NULL; return NULL;
@ -1065,7 +1064,7 @@ static void layout_add(struct wlr_cursor_state *state,
} }
} }
output_cursor = calloc(1, sizeof(struct wlr_cursor_output_cursor)); output_cursor = calloc(1, sizeof(*output_cursor));
if (output_cursor == NULL) { if (output_cursor == NULL) {
wlr_log(WLR_ERROR, "Failed to allocate wlr_cursor_output_cursor"); wlr_log(WLR_ERROR, "Failed to allocate wlr_cursor_output_cursor");
return; return;

View File

@ -288,7 +288,7 @@ static struct wl_resource *create_offer(struct wlr_data_control_device_v1 *devic
struct wl_array *mime_types, bool is_primary) { struct wl_array *mime_types, bool is_primary) {
struct wl_client *client = wl_resource_get_client(device->resource); struct wl_client *client = wl_resource_get_client(device->resource);
struct data_offer *offer = calloc(1, sizeof(struct data_offer)); struct data_offer *offer = calloc(1, sizeof(*offer));
if (offer == NULL) { if (offer == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return NULL; return NULL;
@ -361,8 +361,7 @@ static void control_handle_set_selection(struct wl_client *client,
return; return;
} }
struct client_data_source *client_source = struct client_data_source *client_source = calloc(1, sizeof(*client_source));
calloc(1, sizeof(struct client_data_source));
if (client_source == NULL) { if (client_source == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -414,8 +413,7 @@ static void control_handle_set_primary_selection(struct wl_client *client,
return; return;
} }
struct client_primary_selection_source *client_source = struct client_primary_selection_source *client_source = calloc(1, sizeof(*client_source));
calloc(1, sizeof(struct client_primary_selection_source));
if (client_source == NULL) { if (client_source == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -565,8 +563,7 @@ static struct wlr_data_control_manager_v1 *manager_from_resource(
static void manager_handle_create_data_source(struct wl_client *client, static void manager_handle_create_data_source(struct wl_client *client,
struct wl_resource *manager_resource, uint32_t id) { struct wl_resource *manager_resource, uint32_t id) {
struct data_control_source *source = struct data_control_source *source = calloc(1, sizeof(*source));
calloc(1, sizeof(struct data_control_source));
if (source == NULL) { if (source == NULL) {
wl_resource_post_no_memory(manager_resource); wl_resource_post_no_memory(manager_resource);
return; return;
@ -608,8 +605,7 @@ static void manager_handle_get_data_device(struct wl_client *client,
return; return;
} }
struct wlr_data_control_device_v1 *device = struct wlr_data_control_device_v1 *device = calloc(1, sizeof(*device));
calloc(1, sizeof(struct wlr_data_control_device_v1));
if (device == NULL) { if (device == NULL) {
wl_resource_post_no_memory(manager_resource); wl_resource_post_no_memory(manager_resource);
return; return;
@ -678,8 +674,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_data_control_manager_v1 *wlr_data_control_manager_v1_create( struct wlr_data_control_manager_v1 *wlr_data_control_manager_v1_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_data_control_manager_v1 *manager = struct wlr_data_control_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_data_control_manager_v1));
if (manager == NULL) { if (manager == NULL) {
return NULL; return NULL;
} }

View File

@ -180,8 +180,7 @@ struct wlr_drm_lease_v1 *wlr_drm_lease_request_v1_grant(
return NULL; return NULL;
} }
lease->connectors = calloc(request->n_connectors, lease->connectors = calloc(request->n_connectors, sizeof(*lease->connectors));
sizeof(struct wlr_drm_lease_connector_v1 *));
if (!lease->connectors) { if (!lease->connectors) {
wlr_log(WLR_ERROR, "Failed to allocate lease connectors list"); wlr_log(WLR_ERROR, "Failed to allocate lease connectors list");
close(fd); close(fd);
@ -399,8 +398,7 @@ static void drm_lease_device_v1_handle_create_lease_request(
return; return;
} }
struct wlr_drm_lease_request_v1 *req = struct wlr_drm_lease_request_v1 *req = calloc(1, sizeof(*req));
calloc(1, sizeof(struct wlr_drm_lease_request_v1));
if (!req) { if (!req) {
wlr_log(WLR_ERROR, "Failed to allocate wlr_drm_lease_request_v1"); wlr_log(WLR_ERROR, "Failed to allocate wlr_drm_lease_request_v1");
wl_resource_post_no_memory(resource); wl_resource_post_no_memory(resource);
@ -553,8 +551,7 @@ bool wlr_drm_lease_v1_manager_offer_output(
} }
} }
struct wlr_drm_lease_connector_v1 *connector = struct wlr_drm_lease_connector_v1 *connector = calloc(1, sizeof(*connector));
calloc(1, sizeof(struct wlr_drm_lease_connector_v1));
if (!connector) { if (!connector) {
wlr_log(WLR_ERROR, "Failed to allocate wlr_drm_lease_connector_v1"); wlr_log(WLR_ERROR, "Failed to allocate wlr_drm_lease_connector_v1");
return false; return false;
@ -638,8 +635,7 @@ static void drm_lease_device_v1_create(struct wlr_drm_lease_v1_manager *manager,
wlr_log(WLR_DEBUG, "Creating wlr_drm_lease_device_v1 for %s", wlr_log(WLR_DEBUG, "Creating wlr_drm_lease_device_v1 for %s",
drm_backend->name); drm_backend->name);
struct wlr_drm_lease_device_v1 *lease_device = struct wlr_drm_lease_device_v1 *lease_device = calloc(1, sizeof(*lease_device));
calloc(1, sizeof(struct wlr_drm_lease_device_v1));
if (!lease_device) { if (!lease_device) {
wlr_log(WLR_ERROR, "Failed to allocate wlr_drm_lease_device_v1"); wlr_log(WLR_ERROR, "Failed to allocate wlr_drm_lease_device_v1");
@ -694,8 +690,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_drm_lease_v1_manager *wlr_drm_lease_v1_manager_create( struct wlr_drm_lease_v1_manager *wlr_drm_lease_v1_manager_create(
struct wl_display *display, struct wlr_backend *backend) { struct wl_display *display, struct wlr_backend *backend) {
struct wlr_drm_lease_v1_manager *manager = calloc(1, struct wlr_drm_lease_v1_manager *manager = calloc(1, sizeof(*manager));
sizeof(struct wlr_drm_lease_v1_manager));
if (!manager) { if (!manager) {
wlr_log(WLR_ERROR, "Failed to allocate wlr_drm_lease_v1_manager"); wlr_log(WLR_ERROR, "Failed to allocate wlr_drm_lease_v1_manager");
return NULL; return NULL;

View File

@ -115,8 +115,7 @@ static void manager_handle_capture_output(struct wl_client *client,
manager_from_resource(manager_resource); manager_from_resource(manager_resource);
struct wlr_output *output = wlr_output_from_resource(output_resource); struct wlr_output *output = wlr_output_from_resource(output_resource);
struct wlr_export_dmabuf_frame_v1 *frame = struct wlr_export_dmabuf_frame_v1 *frame = calloc(1, sizeof(*frame));
calloc(1, sizeof(struct wlr_export_dmabuf_frame_v1));
if (frame == NULL) { if (frame == NULL) {
wl_resource_post_no_memory(manager_resource); wl_resource_post_no_memory(manager_resource);
return; return;
@ -200,8 +199,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create( struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_export_dmabuf_manager_v1 *manager = struct wlr_export_dmabuf_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_export_dmabuf_manager_v1));
if (manager == NULL) { if (manager == NULL) {
return NULL; return NULL;
} }

View File

@ -291,8 +291,7 @@ void wlr_foreign_toplevel_handle_v1_output_enter(
} }
} }
toplevel_output = toplevel_output = calloc(1, sizeof(*toplevel_output));
calloc(1, sizeof(struct wlr_foreign_toplevel_handle_v1_output));
if (!toplevel_output) { if (!toplevel_output) {
wlr_log(WLR_ERROR, "failed to allocate memory for toplevel output"); wlr_log(WLR_ERROR, "failed to allocate memory for toplevel output");
return; return;
@ -560,8 +559,7 @@ static struct wl_resource *create_toplevel_resource_for_resource(
struct wlr_foreign_toplevel_handle_v1 * struct wlr_foreign_toplevel_handle_v1 *
wlr_foreign_toplevel_handle_v1_create( wlr_foreign_toplevel_handle_v1_create(
struct wlr_foreign_toplevel_manager_v1 *manager) { struct wlr_foreign_toplevel_manager_v1 *manager) {
struct wlr_foreign_toplevel_handle_v1 *toplevel = calloc(1, struct wlr_foreign_toplevel_handle_v1 *toplevel = calloc(1, sizeof(*toplevel));
sizeof(struct wlr_foreign_toplevel_handle_v1));
if (!toplevel) { if (!toplevel) {
return NULL; return NULL;
} }
@ -685,8 +683,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_foreign_toplevel_manager_v1 *wlr_foreign_toplevel_manager_v1_create( struct wlr_foreign_toplevel_manager_v1 *wlr_foreign_toplevel_manager_v1_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_foreign_toplevel_manager_v1 *manager = calloc(1, struct wlr_foreign_toplevel_manager_v1 *manager = calloc(1, sizeof(*manager));
sizeof(struct wlr_foreign_toplevel_manager_v1));
if (!manager) { if (!manager) {
return NULL; return NULL;
} }

View File

@ -116,8 +116,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_fullscreen_shell_v1 *wlr_fullscreen_shell_v1_create( struct wlr_fullscreen_shell_v1 *wlr_fullscreen_shell_v1_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_fullscreen_shell_v1 *shell = struct wlr_fullscreen_shell_v1 *shell = calloc(1, sizeof(*shell));
calloc(1, sizeof(struct wlr_fullscreen_shell_v1));
if (shell == NULL) { if (shell == NULL) {
return NULL; return NULL;
} }

View File

@ -170,8 +170,7 @@ static void gamma_control_manager_get_gamma_control(struct wl_client *client,
return; return;
} }
struct wlr_gamma_control_v1 *gamma_control = struct wlr_gamma_control_v1 *gamma_control = calloc(1, sizeof(*gamma_control));
calloc(1, sizeof(struct wlr_gamma_control_v1));
if (gamma_control == NULL) { if (gamma_control == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -226,8 +225,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create( struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_gamma_control_manager_v1 *manager = struct wlr_gamma_control_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_gamma_control_manager_v1));
if (!manager) { if (!manager) {
return NULL; return NULL;
} }

View File

@ -101,8 +101,7 @@ static void handle_input_notification(struct wl_listener *listener, void *data)
static struct wlr_idle_timeout *create_timer(struct wlr_idle *idle, static struct wlr_idle_timeout *create_timer(struct wlr_idle *idle,
struct wlr_seat *seat, uint32_t timeout, struct wl_resource *resource) { struct wlr_seat *seat, uint32_t timeout, struct wl_resource *resource) {
struct wlr_idle_timeout *timer = struct wlr_idle_timeout *timer = calloc(1, sizeof(*timer));
calloc(1, sizeof(struct wlr_idle_timeout));
if (!timer) { if (!timer) {
return NULL; return NULL;
} }
@ -221,7 +220,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
} }
struct wlr_idle *wlr_idle_create(struct wl_display *display) { struct wlr_idle *wlr_idle_create(struct wl_display *display) {
struct wlr_idle *idle = calloc(1, sizeof(struct wlr_idle)); struct wlr_idle *idle = calloc(1, sizeof(*idle));
if (!idle) { if (!idle) {
return NULL; return NULL;
} }

View File

@ -70,8 +70,7 @@ static void manager_handle_create_inhibitor(struct wl_client *client,
struct wlr_idle_inhibit_manager_v1 *manager = struct wlr_idle_inhibit_manager_v1 *manager =
wlr_idle_inhibit_manager_v1_from_resource(manager_resource); wlr_idle_inhibit_manager_v1_from_resource(manager_resource);
struct wlr_idle_inhibitor_v1 *inhibitor = struct wlr_idle_inhibitor_v1 *inhibitor = calloc(1, sizeof(*inhibitor));
calloc(1, sizeof(struct wlr_idle_inhibitor_v1));
if (!inhibitor) { if (!inhibitor) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -135,8 +134,7 @@ static void idle_inhibit_bind(struct wl_client *wl_client, void *data,
} }
struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display) { struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display *display) {
struct wlr_idle_inhibit_manager_v1 *manager = struct wlr_idle_inhibit_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_idle_inhibit_manager_v1));
if (!manager) { if (!manager) {
return NULL; return NULL;
} }

View File

@ -114,8 +114,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_input_inhibit_manager *wlr_input_inhibit_manager_create( struct wlr_input_inhibit_manager *wlr_input_inhibit_manager_create(
struct wl_display *display) { struct wl_display *display) {
// TODO: Client destroy // TODO: Client destroy
struct wlr_input_inhibit_manager *manager = struct wlr_input_inhibit_manager *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_input_inhibit_manager));
if (!manager) { if (!manager) {
return NULL; return NULL;
} }

View File

@ -206,8 +206,7 @@ static void im_get_input_popup_surface(struct wl_client *client,
return; return;
} }
struct wlr_input_popup_surface_v2 *popup_surface = struct wlr_input_popup_surface_v2 *popup_surface = calloc(1, sizeof(*popup_surface));
calloc(1, sizeof(struct wlr_input_popup_surface_v2));
if (!popup_surface) { if (!popup_surface) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -410,8 +409,7 @@ static void im_grab_keyboard(struct wl_client *client,
// Already grabbed // Already grabbed
return; return;
} }
struct wlr_input_method_keyboard_grab_v2 *keyboard_grab = struct wlr_input_method_keyboard_grab_v2 *keyboard_grab = calloc(1, sizeof(*keyboard_grab));
calloc(1, sizeof(struct wlr_input_method_keyboard_grab_v2));
if (!keyboard_grab) { if (!keyboard_grab) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -535,8 +533,7 @@ static void manager_get_input_method(struct wl_client *client,
return; return;
} }
struct wlr_input_method_v2 *input_method = calloc(1, struct wlr_input_method_v2 *input_method = calloc(1, sizeof(*input_method));
sizeof(struct wlr_input_method_v2));
if (!input_method) { if (!input_method) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -598,8 +595,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_input_method_manager_v2 *wlr_input_method_manager_v2_create( struct wlr_input_method_manager_v2 *wlr_input_method_manager_v2_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_input_method_manager_v2 *im_manager = calloc(1, struct wlr_input_method_manager_v2 *im_manager = calloc(1, sizeof(*im_manager));
sizeof(struct wlr_input_method_manager_v2));
if (!im_manager) { if (!im_manager) {
return NULL; return NULL;
} }

View File

@ -42,8 +42,7 @@ static const struct wlr_keyboard_impl impl = {
}; };
struct wlr_keyboard_group *wlr_keyboard_group_create(void) { struct wlr_keyboard_group *wlr_keyboard_group_create(void) {
struct wlr_keyboard_group *group = struct wlr_keyboard_group *group = calloc(1, sizeof(*group));
calloc(1, sizeof(struct wlr_keyboard_group));
if (!group) { if (!group) {
wlr_log(WLR_ERROR, "Failed to allocate wlr_keyboard_group"); wlr_log(WLR_ERROR, "Failed to allocate wlr_keyboard_group");
return NULL; return NULL;
@ -93,8 +92,7 @@ static bool process_key(struct keyboard_group_device *group_device,
} }
if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) { if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
struct keyboard_group_key *key = struct keyboard_group_key *key = calloc(1, sizeof(*key));
calloc(1, sizeof(struct keyboard_group_key));
if (!key) { if (!key) {
wlr_log(WLR_ERROR, "Failed to allocate keyboard_group_key"); wlr_log(WLR_ERROR, "Failed to allocate keyboard_group_key");
return false; return false;
@ -256,8 +254,7 @@ bool wlr_keyboard_group_add_keyboard(struct wlr_keyboard_group *group,
return false; return false;
} }
struct keyboard_group_device *device = struct keyboard_group_device *device = calloc(1, sizeof(*device));
calloc(1, sizeof(struct keyboard_group_device));
if (!device) { if (!device) {
wlr_log(WLR_ERROR, "Failed to allocate keyboard_group_device"); wlr_log(WLR_ERROR, "Failed to allocate keyboard_group_device");
return false; return false;

View File

@ -122,8 +122,7 @@ static void manager_handle_inhibit_shortcuts(struct wl_client *client,
return; return;
} }
struct wlr_keyboard_shortcuts_inhibitor_v1 *inhibitor = struct wlr_keyboard_shortcuts_inhibitor_v1 *inhibitor = calloc(1, sizeof(*inhibitor));
calloc(1, sizeof(struct wlr_keyboard_shortcuts_inhibitor_v1));
if (!inhibitor) { if (!inhibitor) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -186,8 +185,7 @@ static void keyboard_shortcuts_inhibit_bind(struct wl_client *wl_client,
struct wlr_keyboard_shortcuts_inhibit_manager_v1 * struct wlr_keyboard_shortcuts_inhibit_manager_v1 *
wlr_keyboard_shortcuts_inhibit_v1_create(struct wl_display *display) { wlr_keyboard_shortcuts_inhibit_v1_create(struct wl_display *display) {
struct wlr_keyboard_shortcuts_inhibit_manager_v1 *manager = struct wlr_keyboard_shortcuts_inhibit_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_keyboard_shortcuts_inhibit_manager_v1));
if (!manager) { if (!manager) {
return NULL; return NULL;
} }

View File

@ -277,8 +277,7 @@ uint32_t wlr_layer_surface_v1_configure(struct wlr_layer_surface_v1 *surface,
uint32_t width, uint32_t height) { uint32_t width, uint32_t height) {
struct wl_display *display = struct wl_display *display =
wl_client_get_display(wl_resource_get_client(surface->resource)); wl_client_get_display(wl_resource_get_client(surface->resource));
struct wlr_layer_surface_v1_configure *configure = struct wlr_layer_surface_v1_configure *configure = calloc(1, sizeof(*configure));
calloc(1, sizeof(struct wlr_layer_surface_v1_configure));
if (configure == NULL) { if (configure == NULL) {
wl_client_post_no_memory(wl_resource_get_client(surface->resource)); wl_client_post_no_memory(wl_resource_get_client(surface->resource));
return surface->pending.configure_serial; return surface->pending.configure_serial;
@ -395,8 +394,7 @@ static void layer_shell_handle_get_layer_surface(struct wl_client *wl_client,
struct wlr_surface *wlr_surface = struct wlr_surface *wlr_surface =
wlr_surface_from_resource(surface_resource); wlr_surface_from_resource(surface_resource);
struct wlr_layer_surface_v1 *surface = struct wlr_layer_surface_v1 *surface = calloc(1, sizeof(*surface));
calloc(1, sizeof(struct wlr_layer_surface_v1));
if (surface == NULL) { if (surface == NULL) {
wl_client_post_no_memory(wl_client); wl_client_post_no_memory(wl_client);
return; return;
@ -485,8 +483,7 @@ struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display,
uint32_t version) { uint32_t version) {
assert(version <= LAYER_SHELL_VERSION); assert(version <= LAYER_SHELL_VERSION);
struct wlr_layer_shell_v1 *layer_shell = struct wlr_layer_shell_v1 *layer_shell = calloc(1, sizeof(*layer_shell));
calloc(1, sizeof(struct wlr_layer_shell_v1));
if (!layer_shell) { if (!layer_shell) {
return NULL; return NULL;
} }

View File

@ -556,8 +556,7 @@ static struct wlr_linux_dmabuf_feedback_v1_compiled *feedback_compile(
munmap(table, table_size); munmap(table, table_size);
struct wlr_linux_dmabuf_feedback_v1_compiled *compiled = calloc(1, struct wlr_linux_dmabuf_feedback_v1_compiled *compiled = calloc(1, sizeof(*compiled) +
sizeof(struct wlr_linux_dmabuf_feedback_v1_compiled) +
tranches_len * sizeof(struct wlr_linux_dmabuf_feedback_v1_compiled_tranche)); tranches_len * sizeof(struct wlr_linux_dmabuf_feedback_v1_compiled_tranche));
if (compiled == NULL) { if (compiled == NULL) {
close(ro_fd); close(ro_fd);
@ -938,8 +937,7 @@ struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *displa
uint32_t version, const struct wlr_linux_dmabuf_feedback_v1 *default_feedback) { uint32_t version, const struct wlr_linux_dmabuf_feedback_v1 *default_feedback) {
assert(version <= LINUX_DMABUF_VERSION); assert(version <= LINUX_DMABUF_VERSION);
struct wlr_linux_dmabuf_v1 *linux_dmabuf = struct wlr_linux_dmabuf_v1 *linux_dmabuf = calloc(1, sizeof(*linux_dmabuf));
calloc(1, sizeof(struct wlr_linux_dmabuf_v1));
if (linux_dmabuf == NULL) { if (linux_dmabuf == NULL) {
wlr_log(WLR_ERROR, "could not create simple dmabuf manager"); wlr_log(WLR_ERROR, "could not create simple dmabuf manager");
return NULL; return NULL;

View File

@ -10,8 +10,7 @@
static const struct wlr_addon_interface addon_impl; static const struct wlr_addon_interface addon_impl;
struct wlr_output_layout *wlr_output_layout_create(void) { struct wlr_output_layout *wlr_output_layout_create(void) {
struct wlr_output_layout *layout = struct wlr_output_layout *layout = calloc(1, sizeof(*layout));
calloc(1, sizeof(struct wlr_output_layout));
if (layout == NULL) { if (layout == NULL) {
return NULL; return NULL;
} }
@ -142,8 +141,7 @@ static const struct wlr_addon_interface addon_impl = {
static struct wlr_output_layout_output *output_layout_output_create( static struct wlr_output_layout_output *output_layout_output_create(
struct wlr_output_layout *layout, struct wlr_output *output) { struct wlr_output_layout *layout, struct wlr_output *output) {
struct wlr_output_layout_output *l_output = struct wlr_output_layout_output *l_output = calloc(1, sizeof(*l_output));
calloc(1, sizeof(struct wlr_output_layout_output));
if (l_output == NULL) { if (l_output == NULL) {
return NULL; return NULL;
} }

View File

@ -117,8 +117,7 @@ static void output_power_manager_get_output_power(struct wl_client *client,
output_power_manager_from_resource(manager_resource); output_power_manager_from_resource(manager_resource);
struct wlr_output *output = wlr_output_from_resource(output_resource); struct wlr_output *output = wlr_output_from_resource(output_resource);
struct wlr_output_power_v1 *output_power = struct wlr_output_power_v1 *output_power = calloc(1, sizeof(*output_power));
calloc(1, sizeof(struct wlr_output_power_v1));
if (output_power == NULL) { if (output_power == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -202,8 +201,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_output_power_manager_v1 *wlr_output_power_manager_v1_create( struct wlr_output_power_manager_v1 *wlr_output_power_manager_v1_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_output_power_manager_v1 *manager = struct wlr_output_power_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_output_power_manager_v1));
if (!manager) { if (!manager) {
return NULL; return NULL;
} }

View File

@ -407,8 +407,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_pointer_gestures_v1 *wlr_pointer_gestures_v1_create( struct wlr_pointer_gestures_v1 *wlr_pointer_gestures_v1_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_pointer_gestures_v1 *gestures = struct wlr_pointer_gestures_v1 *gestures = calloc(1, sizeof(*gestures));
calloc(1, sizeof(struct wlr_pointer_gestures_v1));
if (!gestures) { if (!gestures) {
return NULL; return NULL;
} }

View File

@ -122,7 +122,7 @@ static void presentation_handle_feedback(struct wl_client *client,
struct wlr_presentation_feedback *feedback = p_surface->pending.feedback; struct wlr_presentation_feedback *feedback = p_surface->pending.feedback;
if (feedback == NULL) { if (feedback == NULL) {
feedback = calloc(1, sizeof(struct wlr_presentation_feedback)); feedback = calloc(1, sizeof(*feedback));
if (feedback == NULL) { if (feedback == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -182,8 +182,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_presentation *wlr_presentation_create(struct wl_display *display, struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
struct wlr_backend *backend) { struct wlr_backend *backend) {
struct wlr_presentation *presentation = struct wlr_presentation *presentation = calloc(1, sizeof(*presentation));
calloc(1, sizeof(struct wlr_presentation));
if (presentation == NULL) { if (presentation == NULL) {
return NULL; return NULL;
} }

View File

@ -306,7 +306,7 @@ static struct wlr_primary_selection_v1_device *get_or_create_device(
} }
} }
device = calloc(1, sizeof(struct wlr_primary_selection_v1_device)); device = calloc(1, sizeof(*device));
if (device == NULL) { if (device == NULL) {
return NULL; return NULL;
} }
@ -369,8 +369,7 @@ static struct wlr_primary_selection_v1_device_manager *manager_from_resource(
static void device_manager_handle_create_source(struct wl_client *client, static void device_manager_handle_create_source(struct wl_client *client,
struct wl_resource *manager_resource, uint32_t id) { struct wl_resource *manager_resource, uint32_t id) {
struct client_data_source *source = struct client_data_source *source = calloc(1, sizeof(*source));
calloc(1, sizeof(struct client_data_source));
if (source == NULL) { if (source == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -472,8 +471,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_primary_selection_v1_device_manager * struct wlr_primary_selection_v1_device_manager *
wlr_primary_selection_v1_device_manager_create( wlr_primary_selection_v1_device_manager_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_primary_selection_v1_device_manager *manager = struct wlr_primary_selection_v1_device_manager *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_primary_selection_v1_device_manager));
if (manager == NULL) { if (manager == NULL) {
return NULL; return NULL;
} }

View File

@ -53,7 +53,7 @@ static void region_handle_resource_destroy(struct wl_resource *resource) {
struct wl_resource *region_create(struct wl_client *client, struct wl_resource *region_create(struct wl_client *client,
uint32_t version, uint32_t id) { uint32_t version, uint32_t id) {
pixman_region32_t *region = calloc(1, sizeof(pixman_region32_t)); pixman_region32_t *region = calloc(1, sizeof(*region));
if (region == NULL) { if (region == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return NULL; return NULL;

View File

@ -92,8 +92,7 @@ static void relative_pointer_manager_v1_handle_get_relative_pointer(struct wl_cl
return; return;
} }
struct wlr_relative_pointer_v1 *relative_pointer = struct wlr_relative_pointer_v1 *relative_pointer = calloc(1, sizeof(*relative_pointer));
calloc(1, sizeof(struct wlr_relative_pointer_v1));
if (relative_pointer == NULL) { if (relative_pointer == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -155,8 +154,7 @@ static const struct zwp_relative_pointer_v1_interface relative_pointer_v1_impl =
}; };
struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create(struct wl_display *display) { struct wlr_relative_pointer_manager_v1 *wlr_relative_pointer_manager_v1_create(struct wl_display *display) {
struct wlr_relative_pointer_manager_v1 *manager = struct wlr_relative_pointer_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_relative_pointer_manager_v1));
if (manager == NULL) { if (manager == NULL) {
return NULL; return NULL;
} }

View File

@ -83,8 +83,7 @@ static void screencopy_damage_handle_output_destroy(
static struct screencopy_damage *screencopy_damage_create( static struct screencopy_damage *screencopy_damage_create(
struct wlr_screencopy_v1_client *client, struct wlr_screencopy_v1_client *client,
struct wlr_output *output) { struct wlr_output *output) {
struct screencopy_damage *damage = struct screencopy_damage *damage = calloc(1, sizeof(*damage));
calloc(1, sizeof(struct screencopy_damage));
if (!damage) { if (!damage) {
return NULL; return NULL;
} }
@ -475,8 +474,7 @@ static void capture_output(struct wl_client *wl_client,
struct wlr_screencopy_v1_client *client, uint32_t version, struct wlr_screencopy_v1_client *client, uint32_t version,
uint32_t id, int32_t overlay_cursor, struct wlr_output *output, uint32_t id, int32_t overlay_cursor, struct wlr_output *output,
const struct wlr_box *box) { const struct wlr_box *box) {
struct wlr_screencopy_frame_v1 *frame = struct wlr_screencopy_frame_v1 *frame = calloc(1, sizeof(*frame));
calloc(1, sizeof(struct wlr_screencopy_frame_v1));
if (frame == NULL) { if (frame == NULL) {
wl_client_post_no_memory(wl_client); wl_client_post_no_memory(wl_client);
return; return;
@ -634,8 +632,7 @@ static void manager_bind(struct wl_client *wl_client, void *data,
uint32_t version, uint32_t id) { uint32_t version, uint32_t id) {
struct wlr_screencopy_manager_v1 *manager = data; struct wlr_screencopy_manager_v1 *manager = data;
struct wlr_screencopy_v1_client *client = struct wlr_screencopy_v1_client *client = calloc(1, sizeof(*client));
calloc(1, sizeof(struct wlr_screencopy_v1_client));
if (client == NULL) { if (client == NULL) {
goto failure; goto failure;
} }
@ -670,8 +667,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_screencopy_manager_v1 *wlr_screencopy_manager_v1_create( struct wlr_screencopy_manager_v1 *wlr_screencopy_manager_v1_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_screencopy_manager_v1 *manager = struct wlr_screencopy_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_screencopy_manager_v1));
if (manager == NULL) { if (manager == NULL) {
return NULL; return NULL;
} }

View File

@ -81,8 +81,7 @@ static void server_decoration_manager_handle_create(struct wl_client *client,
manager_from_resource(manager_resource); manager_from_resource(manager_resource);
struct wlr_surface *surface = wlr_surface_from_resource(surface_resource); struct wlr_surface *surface = wlr_surface_from_resource(surface_resource);
struct wlr_server_decoration *decoration = struct wlr_server_decoration *decoration = calloc(1, sizeof(*decoration));
calloc(1, sizeof(struct wlr_server_decoration));
if (decoration == NULL) { if (decoration == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -173,8 +172,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_server_decoration_manager *wlr_server_decoration_manager_create( struct wlr_server_decoration_manager *wlr_server_decoration_manager_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_server_decoration_manager *manager = struct wlr_server_decoration_manager *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_server_decoration_manager));
if (manager == NULL) { if (manager == NULL) {
return NULL; return NULL;
} }

View File

@ -80,8 +80,7 @@ struct wlr_session_lock_surface_v1 *wlr_session_lock_surface_v1_try_from_wlr_sur
uint32_t wlr_session_lock_surface_v1_configure( uint32_t wlr_session_lock_surface_v1_configure(
struct wlr_session_lock_surface_v1 *lock_surface, struct wlr_session_lock_surface_v1 *lock_surface,
uint32_t width, uint32_t height) { uint32_t width, uint32_t height) {
struct wlr_session_lock_surface_v1_configure *configure = struct wlr_session_lock_surface_v1_configure *configure = calloc(1, sizeof(*configure));
calloc(1, sizeof(struct wlr_session_lock_surface_v1_configure));
if (configure == NULL) { if (configure == NULL) {
wl_resource_post_no_memory(lock_surface->resource); wl_resource_post_no_memory(lock_surface->resource);
return lock_surface->pending.configure_serial; return lock_surface->pending.configure_serial;
@ -258,8 +257,7 @@ static void lock_handle_get_lock_surface(struct wl_client *client,
return; return;
} }
struct wlr_session_lock_surface_v1 *lock_surface = struct wlr_session_lock_surface_v1 *lock_surface = calloc(1, sizeof(*lock_surface));
calloc(1, sizeof(struct wlr_session_lock_surface_v1));
if (lock_surface == NULL) { if (lock_surface == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -380,8 +378,7 @@ static void lock_manager_handle_lock(struct wl_client *client,
struct wlr_session_lock_manager_v1 *lock_manager = struct wlr_session_lock_manager_v1 *lock_manager =
lock_manager_from_resource(manager_resource); lock_manager_from_resource(manager_resource);
struct wlr_session_lock_v1 *lock = struct wlr_session_lock_v1 *lock = calloc(1, sizeof(*lock));
calloc(1, sizeof(struct wlr_session_lock_v1));
if (lock == NULL) { if (lock == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -441,8 +438,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
} }
struct wlr_session_lock_manager_v1 *wlr_session_lock_manager_v1_create(struct wl_display *display) { struct wlr_session_lock_manager_v1 *wlr_session_lock_manager_v1_create(struct wl_display *display) {
struct wlr_session_lock_manager_v1 *lock_manager = struct wlr_session_lock_manager_v1 *lock_manager = calloc(1, sizeof(*lock_manager));
calloc(1, sizeof(struct wlr_session_lock_manager_v1));
if (lock_manager == NULL) { if (lock_manager == NULL) {
return NULL; return NULL;
} }

View File

@ -313,7 +313,7 @@ static void subcompositor_handle_get_subsurface(struct wl_client *client,
struct wlr_surface *surface = wlr_surface_from_resource(surface_resource); struct wlr_surface *surface = wlr_surface_from_resource(surface_resource);
struct wlr_surface *parent = wlr_surface_from_resource(parent_resource); struct wlr_surface *parent = wlr_surface_from_resource(parent_resource);
struct wlr_subsurface *subsurface = calloc(1, sizeof(struct wlr_subsurface)); struct wlr_subsurface *subsurface = calloc(1, sizeof(*subsurface));
if (!subsurface) { if (!subsurface) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -394,8 +394,7 @@ static void subcompositor_handle_display_destroy(
} }
struct wlr_subcompositor *wlr_subcompositor_create(struct wl_display *display) { struct wlr_subcompositor *wlr_subcompositor_create(struct wl_display *display) {
struct wlr_subcompositor *subcompositor = struct wlr_subcompositor *subcompositor = calloc(1, sizeof(*subcompositor));
calloc(1, sizeof(*subcompositor));
if (!subcompositor) { if (!subcompositor) {
return NULL; return NULL;
} }

View File

@ -92,8 +92,7 @@ static void tearing_control_manager_handle_get_tearing_control(
return; return;
} }
struct wlr_tearing_control_v1 *hint = calloc(1, sizeof(struct wlr_tearing_control_v1)); struct wlr_tearing_control_v1 *hint = calloc(1, sizeof(*hint));
if (!hint) { if (!hint) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -163,8 +162,7 @@ struct wlr_tearing_control_manager_v1 *wlr_tearing_control_manager_v1_create(
struct wl_display *display, uint32_t version) { struct wl_display *display, uint32_t version) {
assert(version <= TEARING_CONTROL_MANAGER_VERSION); assert(version <= TEARING_CONTROL_MANAGER_VERSION);
struct wlr_tearing_control_manager_v1 *manager = struct wlr_tearing_control_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_tearing_control_manager_v1));
if (!manager) { if (!manager) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;

View File

@ -254,8 +254,7 @@ static void text_input_manager_get_text_input(struct wl_client *client,
return; return;
} }
struct wlr_text_input_v3 *text_input = struct wlr_text_input_v3 *text_input = calloc(1, sizeof(*text_input));
calloc(1, sizeof(struct wlr_text_input_v3));
if (text_input == NULL) { if (text_input == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -318,8 +317,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_text_input_manager_v3 *wlr_text_input_manager_v3_create( struct wlr_text_input_manager_v3 *wlr_text_input_manager_v3_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_text_input_manager_v3 *manager = struct wlr_text_input_manager_v3 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_text_input_manager_v3));
if (!manager) { if (!manager) {
return NULL; return NULL;
} }

View File

@ -169,8 +169,7 @@ static void virtual_keyboard_manager_create_virtual_keyboard(
return; return;
} }
struct wlr_virtual_keyboard_v1 *virtual_keyboard = calloc(1, struct wlr_virtual_keyboard_v1 *virtual_keyboard = calloc(1, sizeof(*virtual_keyboard));
sizeof(struct wlr_virtual_keyboard_v1));
if (!virtual_keyboard) { if (!virtual_keyboard) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -219,8 +218,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_virtual_keyboard_manager_v1* struct wlr_virtual_keyboard_manager_v1*
wlr_virtual_keyboard_manager_v1_create( wlr_virtual_keyboard_manager_v1_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_virtual_keyboard_manager_v1 *manager = calloc(1, struct wlr_virtual_keyboard_manager_v1 *manager = calloc(1, sizeof(*manager));
sizeof(struct wlr_virtual_keyboard_manager_v1));
if (!manager) { if (!manager) {
return NULL; return NULL;
} }

View File

@ -230,8 +230,7 @@ static void virtual_pointer_manager_create_virtual_pointer_with_output(
uint32_t id) { uint32_t id) {
struct wlr_virtual_pointer_manager_v1 *manager = manager_from_resource(resource); struct wlr_virtual_pointer_manager_v1 *manager = manager_from_resource(resource);
struct wlr_virtual_pointer_v1 *virtual_pointer = calloc(1, struct wlr_virtual_pointer_v1 *virtual_pointer = calloc(1, sizeof(*virtual_pointer));
sizeof(struct wlr_virtual_pointer_v1));
if (!virtual_pointer) { if (!virtual_pointer) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -321,8 +320,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_virtual_pointer_manager_v1* wlr_virtual_pointer_manager_v1_create( struct wlr_virtual_pointer_manager_v1* wlr_virtual_pointer_manager_v1_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_virtual_pointer_manager_v1 *manager = calloc(1, struct wlr_virtual_pointer_manager_v1 *manager = calloc(1, sizeof(*manager));
sizeof(struct wlr_virtual_pointer_manager_v1));
if (!manager) { if (!manager) {
return NULL; return NULL;
} }

View File

@ -5,8 +5,7 @@
struct wlr_xcursor_manager *wlr_xcursor_manager_create(const char *name, struct wlr_xcursor_manager *wlr_xcursor_manager_create(const char *name,
uint32_t size) { uint32_t size) {
struct wlr_xcursor_manager *manager = struct wlr_xcursor_manager *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_xcursor_manager));
if (manager == NULL) { if (manager == NULL) {
return NULL; return NULL;
} }
@ -41,7 +40,7 @@ bool wlr_xcursor_manager_load(struct wlr_xcursor_manager *manager,
} }
} }
theme = calloc(1, sizeof(struct wlr_xcursor_manager_theme)); theme = calloc(1, sizeof(*theme));
if (theme == NULL) { if (theme == NULL) {
return false; return false;
} }

View File

@ -96,8 +96,7 @@ static void toplevel_decoration_handle_surface_configure(
return; return;
} }
struct wlr_xdg_toplevel_decoration_v1_configure *configure = struct wlr_xdg_toplevel_decoration_v1_configure *configure = calloc(1, sizeof(*configure));
calloc(1, sizeof(struct wlr_xdg_toplevel_decoration_v1_configure));
if (configure == NULL) { if (configure == NULL) {
return; return;
} }
@ -197,8 +196,7 @@ static void decoration_manager_handle_get_toplevel_decoration(
} }
} }
struct wlr_xdg_toplevel_decoration_v1 *decoration = struct wlr_xdg_toplevel_decoration_v1 *decoration = calloc(1, sizeof(*decoration));
calloc(1, sizeof(struct wlr_xdg_toplevel_decoration_v1));
if (decoration == NULL) { if (decoration == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -282,8 +280,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_xdg_decoration_manager_v1 * struct wlr_xdg_decoration_manager_v1 *
wlr_xdg_decoration_manager_v1_create(struct wl_display *display) { wlr_xdg_decoration_manager_v1_create(struct wl_display *display) {
struct wlr_xdg_decoration_manager_v1 *manager = struct wlr_xdg_decoration_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_xdg_decoration_manager_v1));
if (manager == NULL) { if (manager == NULL) {
return NULL; return NULL;
} }

View File

@ -92,7 +92,7 @@ static void xdg_imported_handle_set_parent_of(struct wl_client *client,
} }
} }
child = calloc(1, sizeof(struct wlr_xdg_imported_child_v1)); child = calloc(1, sizeof(*child));
if (child == NULL) { if (child == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -211,8 +211,7 @@ static void xdg_exporter_handle_export(struct wl_client *wl_client,
return; return;
} }
struct wlr_xdg_exported_v1 *exported = struct wlr_xdg_exported_v1 *exported = calloc(1, sizeof(*exported));
calloc(1, sizeof(struct wlr_xdg_exported_v1));
if (exported == NULL) { if (exported == NULL) {
wl_client_post_no_memory(wl_client); wl_client_post_no_memory(wl_client);
return; return;
@ -302,8 +301,7 @@ static void xdg_importer_handle_import(struct wl_client *wl_client,
struct wlr_xdg_foreign_v1 *foreign = struct wlr_xdg_foreign_v1 *foreign =
xdg_foreign_from_importer_resource(client_resource); xdg_foreign_from_importer_resource(client_resource);
struct wlr_xdg_imported_v1 *imported = struct wlr_xdg_imported_v1 *imported = calloc(1, sizeof(*imported));
calloc(1, sizeof(struct wlr_xdg_imported_v1));
if (imported == NULL) { if (imported == NULL) {
wl_client_post_no_memory(wl_client); wl_client_post_no_memory(wl_client);
return; return;
@ -386,8 +384,7 @@ static void handle_foreign_registry_destroy(struct wl_listener *listener,
struct wlr_xdg_foreign_v1 *wlr_xdg_foreign_v1_create( struct wlr_xdg_foreign_v1 *wlr_xdg_foreign_v1_create(
struct wl_display *display, struct wlr_xdg_foreign_registry *registry) { struct wl_display *display, struct wlr_xdg_foreign_registry *registry) {
struct wlr_xdg_foreign_v1 *foreign = calloc(1, struct wlr_xdg_foreign_v1 *foreign = calloc(1, sizeof(*foreign));
sizeof(struct wlr_xdg_foreign_v1));
if (!foreign) { if (!foreign) {
return NULL; return NULL;
} }

View File

@ -95,7 +95,7 @@ static void xdg_imported_handle_set_parent_of(struct wl_client *client,
} }
} }
child = calloc(1, sizeof(struct wlr_xdg_imported_child_v2)); child = calloc(1, sizeof(*child));
if (child == NULL) { if (child == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
@ -214,8 +214,7 @@ static void xdg_exporter_handle_export(struct wl_client *wl_client,
return; return;
} }
struct wlr_xdg_exported_v2 *exported = struct wlr_xdg_exported_v2 *exported = calloc(1, sizeof(*exported));
calloc(1, sizeof(struct wlr_xdg_exported_v2));
if (exported == NULL) { if (exported == NULL) {
wl_client_post_no_memory(wl_client); wl_client_post_no_memory(wl_client);
return; return;
@ -305,8 +304,7 @@ static void xdg_importer_handle_import(struct wl_client *wl_client,
struct wlr_xdg_foreign_v2 *foreign = struct wlr_xdg_foreign_v2 *foreign =
xdg_foreign_from_importer_resource(client_resource); xdg_foreign_from_importer_resource(client_resource);
struct wlr_xdg_imported_v2 *imported = struct wlr_xdg_imported_v2 *imported = calloc(1, sizeof(*imported));
calloc(1, sizeof(struct wlr_xdg_imported_v2));
if (imported == NULL) { if (imported == NULL) {
wl_client_post_no_memory(wl_client); wl_client_post_no_memory(wl_client);
return; return;
@ -389,8 +387,7 @@ static void handle_foreign_registry_destroy(struct wl_listener *listener,
struct wlr_xdg_foreign_v2 *wlr_xdg_foreign_v2_create( struct wlr_xdg_foreign_v2 *wlr_xdg_foreign_v2_create(
struct wl_display *display, struct wlr_xdg_foreign_registry *registry) { struct wl_display *display, struct wlr_xdg_foreign_registry *registry) {
struct wlr_xdg_foreign_v2 *foreign = calloc(1, struct wlr_xdg_foreign_v2 *foreign = calloc(1, sizeof(*foreign));
sizeof(struct wlr_xdg_foreign_v2));
if (!foreign) { if (!foreign) {
return NULL; return NULL;
} }

View File

@ -192,7 +192,7 @@ static void handle_output_description(struct wl_listener *listener,
static void add_output(struct wlr_xdg_output_manager_v1 *manager, static void add_output(struct wlr_xdg_output_manager_v1 *manager,
struct wlr_output_layout_output *layout_output) { struct wlr_output_layout_output *layout_output) {
struct wlr_xdg_output_v1 *output = calloc(1, sizeof(struct wlr_xdg_output_v1)); struct wlr_xdg_output_v1 *output = calloc(1, sizeof(*output));
if (output == NULL) { if (output == NULL) {
return; return;
} }
@ -256,8 +256,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_xdg_output_manager_v1 *wlr_xdg_output_manager_v1_create( struct wlr_xdg_output_manager_v1 *wlr_xdg_output_manager_v1_create(
struct wl_display *display, struct wlr_output_layout *layout) { struct wl_display *display, struct wlr_output_layout *layout) {
struct wlr_xdg_output_manager_v1 *manager = struct wlr_xdg_output_manager_v1 *manager = calloc(1, sizeof(*manager));
calloc(1, sizeof(struct wlr_xdg_output_manager_v1));
if (manager == NULL) { if (manager == NULL) {
return NULL; return NULL;
} }

View File

@ -12,8 +12,7 @@ void handle_xdg_popup_ack_configure(
struct wlr_xdg_popup_configure *send_xdg_popup_configure( struct wlr_xdg_popup_configure *send_xdg_popup_configure(
struct wlr_xdg_popup *popup) { struct wlr_xdg_popup *popup) {
struct wlr_xdg_popup_configure *configure = struct wlr_xdg_popup_configure *configure = calloc(1, sizeof(*configure));
calloc(1, sizeof(*configure));
if (configure == NULL) { if (configure == NULL) {
wl_resource_post_no_memory(popup->resource); wl_resource_post_no_memory(popup->resource);
return NULL; return NULL;
@ -214,7 +213,7 @@ static struct wlr_xdg_popup_grab *get_xdg_shell_popup_grab_from_seat(
} }
} }
xdg_grab = calloc(1, sizeof(struct wlr_xdg_popup_grab)); xdg_grab = calloc(1, sizeof(*xdg_grab));
if (!xdg_grab) { if (!xdg_grab) {
return NULL; return NULL;
} }
@ -382,7 +381,7 @@ void create_xdg_popup(struct wlr_xdg_surface *surface,
} }
assert(surface->popup == NULL); assert(surface->popup == NULL);
surface->popup = calloc(1, sizeof(struct wlr_xdg_popup)); surface->popup = calloc(1, sizeof(*surface->popup));
if (!surface->popup) { if (!surface->popup) {
wl_resource_post_no_memory(surface->resource); wl_resource_post_no_memory(surface->resource);
return; return;

View File

@ -95,8 +95,7 @@ static void xdg_shell_bind(struct wl_client *wl_client, void *data,
struct wlr_xdg_shell *xdg_shell = data; struct wlr_xdg_shell *xdg_shell = data;
assert(wl_client && xdg_shell); assert(wl_client && xdg_shell);
struct wlr_xdg_client *client = struct wlr_xdg_client *client = calloc(1, sizeof(*client));
calloc(1, sizeof(struct wlr_xdg_client));
if (client == NULL) { if (client == NULL) {
wl_client_post_no_memory(wl_client); wl_client_post_no_memory(wl_client);
return; return;
@ -140,8 +139,7 @@ struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display,
uint32_t version) { uint32_t version) {
assert(version <= WM_BASE_VERSION); assert(version <= WM_BASE_VERSION);
struct wlr_xdg_shell *xdg_shell = struct wlr_xdg_shell *xdg_shell = calloc(1, sizeof(*xdg_shell));
calloc(1, sizeof(struct wlr_xdg_shell));
if (!xdg_shell) { if (!xdg_shell) {
return NULL; return NULL;
} }

View File

@ -129,8 +129,7 @@ static void surface_send_configure(void *user_data) {
surface->configure_idle = NULL; surface->configure_idle = NULL;
struct wlr_xdg_surface_configure *configure = struct wlr_xdg_surface_configure *configure = calloc(1, sizeof(*configure));
calloc(1, sizeof(struct wlr_xdg_surface_configure));
if (configure == NULL) { if (configure == NULL) {
wl_client_post_no_memory(surface->client->client); wl_client_post_no_memory(surface->client->client);
return; return;
@ -352,8 +351,7 @@ void create_xdg_surface(struct wlr_xdg_client *client, struct wlr_surface *wlr_s
return; return;
} }
struct wlr_xdg_surface *surface = struct wlr_xdg_surface *surface = calloc(1, sizeof(*surface));
calloc(1, sizeof(struct wlr_xdg_surface));
if (surface == NULL) { if (surface == NULL) {
wl_client_post_no_memory(client->client); wl_client_post_no_memory(client->client);
return; return;

View File

@ -475,7 +475,7 @@ void create_xdg_toplevel(struct wlr_xdg_surface *surface,
} }
assert(surface->toplevel == NULL); assert(surface->toplevel == NULL);
surface->toplevel = calloc(1, sizeof(struct wlr_xdg_toplevel)); surface->toplevel = calloc(1, sizeof(*surface->toplevel));
if (surface->toplevel == NULL) { if (surface->toplevel == NULL) {
wl_resource_post_no_memory(surface->resource); wl_resource_post_no_memory(surface->resource);
return; return;

View File

@ -149,7 +149,7 @@ xcursor_image_create(int width, int height)
if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE)
return NULL; return NULL;
image = malloc(sizeof(struct xcursor_image) + image = malloc(sizeof(*image) +
width * height * sizeof(uint32_t)); width * height * sizeof(uint32_t));
if (!image) if (!image)
return NULL; return NULL;
@ -173,7 +173,7 @@ xcursor_images_create(int size)
{ {
struct xcursor_images *images; struct xcursor_images *images;
images = malloc(sizeof(struct xcursor_images) + images = malloc(sizeof(*images) +
size * sizeof(struct xcursor_image *)); size * sizeof(struct xcursor_image *));
if (!images) if (!images)
return NULL; return NULL;
@ -228,7 +228,7 @@ xcursor_file_header_create(uint32_t ntoc)
if (ntoc > 0x10000) if (ntoc > 0x10000)
return NULL; return NULL;
file_header = malloc(sizeof(struct xcursor_file_header) + file_header = malloc(sizeof(*file_header) +
ntoc * sizeof(struct xcursor_file_toc)); ntoc * sizeof(struct xcursor_file_toc));
if (!file_header) if (!file_header)
return NULL; return NULL;

View File

@ -402,8 +402,7 @@ static void xwm_selection_get_targets(struct wlr_xwm_selection *selection) {
struct wlr_xwm *xwm = selection->xwm; struct wlr_xwm *xwm = selection->xwm;
if (selection == &xwm->clipboard_selection) { if (selection == &xwm->clipboard_selection) {
struct x11_data_source *source = struct x11_data_source *source = calloc(1, sizeof(*source));
calloc(1, sizeof(struct x11_data_source));
if (source == NULL) { if (source == NULL) {
return; return;
} }
@ -421,8 +420,7 @@ static void xwm_selection_get_targets(struct wlr_xwm_selection *selection) {
wlr_data_source_destroy(&source->base); wlr_data_source_destroy(&source->base);
} }
} else if (selection == &xwm->primary_selection) { } else if (selection == &xwm->primary_selection) {
struct x11_primary_selection_source *source = struct x11_primary_selection_source *source = calloc(1, sizeof(*source));
calloc(1, sizeof(struct x11_primary_selection_source));
if (source == NULL) { if (source == NULL) {
return; return;
} }

View File

@ -269,8 +269,7 @@ static bool xwm_selection_send_data(struct wlr_xwm_selection *selection,
return false; return false;
} }
struct wlr_xwm_selection_transfer *transfer = struct wlr_xwm_selection_transfer *transfer = calloc(1, sizeof(*transfer));
calloc(1, sizeof(struct wlr_xwm_selection_transfer));
if (transfer == NULL) { if (transfer == NULL) {
wlr_log(WLR_ERROR, "Allocation failed"); wlr_log(WLR_ERROR, "Allocation failed");
return false; return false;

View File

@ -454,8 +454,7 @@ struct wlr_xwayland_server *wlr_xwayland_server_create(
return NULL; return NULL;
} }
struct wlr_xwayland_server *server = struct wlr_xwayland_server *server = calloc(1, sizeof(*server));
calloc(1, sizeof(struct wlr_xwayland_server));
if (!server) { if (!server) {
return NULL; return NULL;
} }

View File

@ -82,7 +82,7 @@ void wlr_xwayland_destroy(struct wlr_xwayland *xwayland) {
struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display, struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display,
struct wlr_compositor *compositor, bool lazy) { struct wlr_compositor *compositor, bool lazy) {
struct wlr_xwayland *xwayland = calloc(1, sizeof(struct wlr_xwayland)); struct wlr_xwayland *xwayland = calloc(1, sizeof(*xwayland));
if (!xwayland) { if (!xwayland) {
return NULL; return NULL;
} }
@ -139,7 +139,7 @@ void wlr_xwayland_set_cursor(struct wlr_xwayland *xwayland,
free(xwayland->cursor); free(xwayland->cursor);
xwayland->cursor = calloc(1, sizeof(struct wlr_xwayland_cursor)); xwayland->cursor = calloc(1, sizeof(*xwayland->cursor));
if (xwayland->cursor == NULL) { if (xwayland->cursor == NULL) {
return; return;
} }

View File

@ -135,8 +135,7 @@ static int xwayland_surface_handle_ping_timeout(void *data) {
static struct wlr_xwayland_surface *xwayland_surface_create( static struct wlr_xwayland_surface *xwayland_surface_create(
struct wlr_xwm *xwm, xcb_window_t window_id, int16_t x, int16_t y, struct wlr_xwm *xwm, xcb_window_t window_id, int16_t x, int16_t y,
uint16_t width, uint16_t height, bool override_redirect) { uint16_t width, uint16_t height, bool override_redirect) {
struct wlr_xwayland_surface *surface = struct wlr_xwayland_surface *surface = calloc(1, sizeof(*surface));
calloc(1, sizeof(struct wlr_xwayland_surface));
if (!surface) { if (!surface) {
wlr_log(WLR_ERROR, "Could not allocate wlr xwayland surface"); wlr_log(WLR_ERROR, "Could not allocate wlr xwayland surface");
return NULL; return NULL;
@ -681,7 +680,7 @@ static void read_surface_hints(struct wlr_xwm *xwm,
} }
free(xsurface->hints); free(xsurface->hints);
xsurface->hints = calloc(1, sizeof(xcb_icccm_wm_hints_t)); xsurface->hints = calloc(1, sizeof(*xsurface->hints));
if (xsurface->hints == NULL) { if (xsurface->hints == NULL) {
return; return;
} }
@ -704,7 +703,7 @@ static void read_surface_normal_hints(struct wlr_xwm *xwm,
} }
free(xsurface->size_hints); free(xsurface->size_hints);
xsurface->size_hints = calloc(1, sizeof(xcb_size_hints_t)); xsurface->size_hints = calloc(1, sizeof(*xsurface->size_hints));
if (xsurface->size_hints == NULL) { if (xsurface->size_hints == NULL) {
return; return;
} }
@ -777,7 +776,7 @@ static void read_surface_strut_partial(struct wlr_xwm *xwm,
} }
free(xsurface->strut_partial); free(xsurface->strut_partial);
xsurface->strut_partial = calloc(1, sizeof(xcb_ewmh_wm_strut_partial_t)); xsurface->strut_partial = calloc(1, sizeof(*xsurface->strut_partial));
if (xsurface->strut_partial == NULL) { if (xsurface->strut_partial == NULL) {
return; return;
} }
@ -1433,7 +1432,7 @@ static void xwm_handle_net_startup_info_message(struct wlr_xwm *xwm,
start = curr->msg + curr->len; start = curr->msg + curr->len;
curr->len += buf_len; curr->len += buf_len;
} else { } else {
curr = calloc(1, sizeof(struct pending_startup_id)); curr = calloc(1, sizeof(*curr));
if (!curr) if (!curr)
return; return;
curr->window = ev->window; curr->window = ev->window;
@ -2111,7 +2110,7 @@ void xwm_set_cursor(struct wlr_xwm *xwm, const uint8_t *pixels, uint32_t stride,
} }
struct wlr_xwm *xwm_create(struct wlr_xwayland *xwayland, int wm_fd) { struct wlr_xwm *xwm_create(struct wlr_xwayland *xwayland, int wm_fd) {
struct wlr_xwm *xwm = calloc(1, sizeof(struct wlr_xwm)); struct wlr_xwm *xwm = calloc(1, sizeof(*xwm));
if (xwm == NULL) { if (xwm == NULL) {
return NULL; return NULL;
} }