mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical
This commit is contained in:
parent
a09d649439
commit
1b0694b794
99 changed files with 224 additions and 355 deletions
|
|
@ -117,7 +117,7 @@ bool create_gamma_lut_blob(struct wlr_drm_backend *drm,
|
|||
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) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate gamma table");
|
||||
return false;
|
||||
|
|
@ -133,7 +133,7 @@ bool create_gamma_lut_blob(struct wlr_drm_backend *drm,
|
|||
}
|
||||
|
||||
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");
|
||||
free(gamma);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
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) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -67,8 +67,7 @@ struct wlr_drm_backend_monitor *drm_backend_monitor_create(
|
|||
struct wlr_backend *multi,
|
||||
struct wlr_backend *primary_drm,
|
||||
struct wlr_session *session) {
|
||||
struct wlr_drm_backend_monitor *monitor =
|
||||
calloc(1, sizeof(struct wlr_drm_backend_monitor));
|
||||
struct wlr_drm_backend_monitor *monitor = calloc(1, sizeof(*monitor));
|
||||
if (!monitor) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
wlr_log(WLR_INFO, "Creating headless backend");
|
||||
|
||||
struct wlr_headless_backend *backend =
|
||||
calloc(1, sizeof(struct wlr_headless_backend));
|
||||
struct wlr_headless_backend *backend = calloc(1, sizeof(*backend));
|
||||
if (!backend) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate wlr_headless_backend");
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -107,8 +107,7 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
|
|||
struct wlr_headless_backend *backend =
|
||||
headless_backend_from_backend(wlr_backend);
|
||||
|
||||
struct wlr_headless_output *output =
|
||||
calloc(1, sizeof(struct wlr_headless_output));
|
||||
struct wlr_headless_output *output = calloc(1, sizeof(*output));
|
||||
if (output == NULL) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate wlr_headless_output");
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -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_session *session) {
|
||||
struct wlr_libinput_backend *backend =
|
||||
calloc(1, sizeof(struct wlr_libinput_backend));
|
||||
struct wlr_libinput_backend *backend = calloc(1, sizeof(*backend));
|
||||
if (!backend) {
|
||||
wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno));
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -69,8 +69,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
const char *name = libinput_device_get_name(libinput_dev);
|
||||
wlr_log(WLR_DEBUG, "Adding %s [%d:%d]", name, vendor, product);
|
||||
|
||||
struct wlr_libinput_input_device *dev =
|
||||
calloc(1, sizeof(struct wlr_libinput_input_device));
|
||||
struct wlr_libinput_input_device *dev = calloc(1, sizeof(*dev));
|
||||
if (dev == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "failed to allocate wlr_libinput_input_device");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -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_tablet_pad_mode_group *li_group =
|
||||
libinput_device_tablet_pad_get_mode_group(device, index);
|
||||
struct wlr_tablet_pad_group *group =
|
||||
calloc(1, sizeof(struct wlr_tablet_pad_group));
|
||||
struct wlr_tablet_pad_group *group = calloc(1, sizeof(*group));
|
||||
if (!group) {
|
||||
wlr_log_errno(WLR_ERROR, "failed to allocate wlr_tablet_pad_group");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ static struct tablet_tool *get_tablet_tool(
|
|||
return tool;
|
||||
}
|
||||
|
||||
tool = calloc(1, sizeof(struct tablet_tool));
|
||||
tool = calloc(1, sizeof(*tool));
|
||||
if (tool == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "failed to allocate wlr_libinput_tablet_tool");
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -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_multi_backend *backend =
|
||||
calloc(1, sizeof(struct wlr_multi_backend));
|
||||
struct wlr_multi_backend *backend = calloc(1, sizeof(*backend));
|
||||
if (!backend) {
|
||||
wlr_log(WLR_ERROR, "Backend allocation failed");
|
||||
return NULL;
|
||||
|
|
@ -191,7 +190,7 @@ bool wlr_multi_backend_add(struct wlr_backend *_multi,
|
|||
return true;
|
||||
}
|
||||
|
||||
struct subbackend_state *sub = calloc(1, sizeof(struct subbackend_state));
|
||||
struct subbackend_state *sub = calloc(1, sizeof(*sub));
|
||||
if (sub == NULL) {
|
||||
wlr_log(WLR_ERROR, "Could not add backend: allocation failed");
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ static char *get_render_name(const char *name) {
|
|||
wlr_log(WLR_ERROR, "drmGetDevices2 failed: %s", strerror(-devices_len));
|
||||
return NULL;
|
||||
}
|
||||
drmDevice **devices = calloc(devices_len, sizeof(drmDevice *));
|
||||
drmDevice **devices = calloc(devices_len, sizeof(*devices));
|
||||
if (devices == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ static struct wlr_wl_buffer *create_wl_buffer(struct wlr_wl_backend *wl,
|
|||
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) {
|
||||
wl_buffer_destroy(wl_buffer);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -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'",
|
||||
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) {
|
||||
wlr_log(WLR_ERROR, "failed to allocate wlr_wl_pointer");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
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) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -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_ring_v2 *ring) {
|
||||
struct tablet_pad_group *group = data;
|
||||
struct tablet_pad_ring *tablet_ring =
|
||||
calloc(1, sizeof(struct tablet_pad_ring));
|
||||
struct tablet_pad_ring *tablet_ring = calloc(1, sizeof(*tablet_ring));
|
||||
if (!tablet_ring) {
|
||||
zwp_tablet_pad_ring_v2_destroy(ring);
|
||||
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_strip_v2 *strip) {
|
||||
struct tablet_pad_group *group = data;
|
||||
struct tablet_pad_strip *tablet_strip =
|
||||
calloc(1, sizeof(struct tablet_pad_strip));
|
||||
struct tablet_pad_strip *tablet_strip = calloc(1, sizeof(*tablet_strip));
|
||||
if (!tablet_strip) {
|
||||
zwp_tablet_pad_strip_v2_destroy(strip);
|
||||
return;
|
||||
|
|
@ -296,8 +294,7 @@ static void handle_tablet_pad_group(void *data,
|
|||
struct wlr_wl_seat *seat = data;
|
||||
struct wlr_tablet_pad *pad = &seat->wlr_tablet_pad;
|
||||
|
||||
struct tablet_pad_group *group =
|
||||
calloc(1, sizeof(struct tablet_pad_group));
|
||||
struct tablet_pad_group *group = calloc(1, sizeof(*group));
|
||||
if (!group) {
|
||||
wlr_log_errno(WLR_ERROR, "failed to allocate tablet_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);
|
||||
|
||||
struct tablet_tool *tool = calloc(1, sizeof(struct tablet_tool));
|
||||
struct tablet_tool *tool = calloc(1, sizeof(*tool));
|
||||
if (tool == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "failed to allocate tablet_tool");
|
||||
zwp_tablet_tool_v2_destroy(zwp_tablet_tool_v2);
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ void handle_x11_xinput_event(struct wlr_x11_backend *x11,
|
|||
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->wayland_id = id;
|
||||
wl_list_init(&touchpoint->link);
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ static struct wlr_x11_buffer *create_x11_buffer(struct wlr_x11_output *output,
|
|||
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) {
|
||||
xcb_free_pixmap(x11->xcb, pixmap);
|
||||
return NULL;
|
||||
|
|
@ -535,7 +535,7 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
|||
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) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue