mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05: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
14
render/egl.c
14
render/egl.c
|
|
@ -210,7 +210,7 @@ static struct wlr_egl *egl_create(void) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_egl *egl = calloc(1, sizeof(struct wlr_egl));
|
||||
struct wlr_egl *egl = calloc(1, sizeof(*egl));
|
||||
if (egl == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return NULL;
|
||||
|
|
@ -457,7 +457,7 @@ static EGLDeviceEXT get_egl_device_from_drm_fd(struct wlr_egl *egl,
|
|||
return EGL_NO_DEVICE_EXT;
|
||||
}
|
||||
|
||||
EGLDeviceEXT *devices = calloc(nb_devices, sizeof(EGLDeviceEXT));
|
||||
EGLDeviceEXT *devices = calloc(nb_devices, sizeof(*devices));
|
||||
if (devices == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Failed to allocate EGL device list");
|
||||
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]);
|
||||
|
||||
*formats = calloc(num, sizeof(EGLint));
|
||||
*formats = calloc(num, sizeof(**formats));
|
||||
if (!*formats) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return -1;
|
||||
|
|
@ -823,7 +823,7 @@ static int get_egl_dmabuf_formats(struct wlr_egl *egl, EGLint **formats) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
*formats = calloc(num, sizeof(EGLint));
|
||||
*formats = calloc(num, sizeof(**formats));
|
||||
if (*formats == NULL) {
|
||||
wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno));
|
||||
return -1;
|
||||
|
|
@ -860,12 +860,12 @@ static int get_egl_dmabuf_modifiers(struct wlr_egl *egl, EGLint format,
|
|||
return 0;
|
||||
}
|
||||
|
||||
*modifiers = calloc(num, sizeof(uint64_t));
|
||||
*modifiers = calloc(num, sizeof(**modifiers));
|
||||
if (*modifiers == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return -1;
|
||||
}
|
||||
*external_only = calloc(num, sizeof(EGLBoolean));
|
||||
*external_only = calloc(num, sizeof(**external_only));
|
||||
if (*external_only == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
free(*modifiers);
|
||||
|
|
@ -912,7 +912,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;
|
||||
|
|
|
|||
|
|
@ -583,7 +583,7 @@ static struct wlr_render_timer *gles2_render_timer_create(struct wlr_renderer *w
|
|||
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) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -826,8 +826,7 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_gles2_renderer *renderer =
|
||||
calloc(1, sizeof(struct wlr_gles2_renderer));
|
||||
struct wlr_gles2_renderer *renderer = calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,8 +174,7 @@ static const struct wlr_texture_impl texture_impl = {
|
|||
|
||||
static struct wlr_gles2_texture *gles2_texture_create(
|
||||
struct wlr_gles2_renderer *renderer, uint32_t width, uint32_t height) {
|
||||
struct wlr_gles2_texture *texture =
|
||||
calloc(1, sizeof(struct wlr_gles2_texture));
|
||||
struct wlr_gles2_texture *texture = calloc(1, sizeof(*texture));
|
||||
if (texture == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -341,8 +341,7 @@ static const struct wlr_drm_format_set *pixman_get_render_formats(
|
|||
static struct wlr_pixman_texture *pixman_texture_create(
|
||||
struct wlr_pixman_renderer *renderer, uint32_t drm_format,
|
||||
uint32_t width, uint32_t height) {
|
||||
struct wlr_pixman_texture *texture =
|
||||
calloc(1, sizeof(struct wlr_pixman_texture));
|
||||
struct wlr_pixman_texture *texture = calloc(1, sizeof(*texture));
|
||||
if (texture == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Failed to allocate pixman texture");
|
||||
return NULL;
|
||||
|
|
@ -530,8 +529,7 @@ static const struct wlr_renderer_impl renderer_impl = {
|
|||
};
|
||||
|
||||
struct wlr_renderer *wlr_pixman_renderer_create(void) {
|
||||
struct wlr_pixman_renderer *renderer =
|
||||
calloc(1, sizeof(struct wlr_pixman_renderer));
|
||||
struct wlr_pixman_renderer *renderer = calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,9 +118,9 @@ static bool render_pass_submit(struct wlr_render_pass *wlr_pass) {
|
|||
|
||||
// insert acquire and release barriers for dmabuf-images
|
||||
uint32_t barrier_count = wl_list_length(&renderer->foreign_textures) + 1;
|
||||
VkImageMemoryBarrier *acquire_barriers = calloc(barrier_count, sizeof(VkImageMemoryBarrier));
|
||||
VkImageMemoryBarrier *release_barriers = calloc(barrier_count, sizeof(VkImageMemoryBarrier));
|
||||
render_wait = calloc(barrier_count * WLR_DMABUF_MAX_PLANES, sizeof(VkSemaphoreSubmitInfoKHR));
|
||||
VkImageMemoryBarrier *acquire_barriers = calloc(barrier_count, sizeof(*acquire_barriers));
|
||||
VkImageMemoryBarrier *release_barriers = calloc(barrier_count, sizeof(*release_barriers));
|
||||
render_wait = calloc(barrier_count * WLR_DMABUF_MAX_PLANES, sizeof(*render_wait));
|
||||
if (acquire_barriers == NULL || release_barriers == NULL || render_wait == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
free(acquire_barriers);
|
||||
|
|
|
|||
|
|
@ -1117,9 +1117,9 @@ static void vulkan_end(struct wlr_renderer *wlr_renderer) {
|
|||
|
||||
// insert acquire and release barriers for dmabuf-images
|
||||
unsigned barrier_count = wl_list_length(&renderer->foreign_textures) + 1;
|
||||
VkImageMemoryBarrier *acquire_barriers = calloc(barrier_count, sizeof(VkImageMemoryBarrier));
|
||||
VkImageMemoryBarrier *release_barriers = calloc(barrier_count, sizeof(VkImageMemoryBarrier));
|
||||
VkSemaphoreSubmitInfoKHR *render_wait = calloc(barrier_count * WLR_DMABUF_MAX_PLANES, sizeof(VkSemaphoreSubmitInfoKHR));
|
||||
VkImageMemoryBarrier *acquire_barriers = calloc(barrier_count, sizeof(*acquire_barriers));
|
||||
VkImageMemoryBarrier *release_barriers = calloc(barrier_count, sizeof(*release_barriers));
|
||||
VkSemaphoreSubmitInfoKHR *render_wait = calloc(barrier_count * WLR_DMABUF_MAX_PLANES, sizeof(*render_wait));
|
||||
if (acquire_barriers == NULL || release_barriers == NULL || render_wait == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
free(acquire_barriers);
|
||||
|
|
|
|||
|
|
@ -256,8 +256,7 @@ static const struct wlr_texture_impl texture_impl = {
|
|||
|
||||
static struct wlr_vk_texture *vulkan_texture_create(
|
||||
struct wlr_vk_renderer *renderer, uint32_t width, uint32_t height) {
|
||||
struct wlr_vk_texture *texture =
|
||||
calloc(1, sizeof(struct wlr_vk_texture));
|
||||
struct wlr_vk_texture *texture = calloc(1, sizeof(*texture));
|
||||
if (texture == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ static int open_drm_render_node(void) {
|
|||
wlr_log(WLR_ERROR, "drmGetDevices2 failed: %s", strerror(-devices_len));
|
||||
return -1;
|
||||
}
|
||||
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 -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue