aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorAlexander Orzechowski <alex@ozal.ski>2023-10-03 01:51:07 -0400
committerAlexander Orzechowski <alex@ozal.ski>2023-10-03 01:51:07 -0400
commit1b0694b79481643cb456d03e1be50a1b4f6ca591 (patch)
treec693c5de3ee7ebd52873f6ec063118408f0bd28a /render
parenta09d6494397bdd28a3254d2e646212afb5a3049c (diff)
treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical
Diffstat (limited to 'render')
-rw-r--r--render/egl.c14
-rw-r--r--render/gles2/renderer.c5
-rw-r--r--render/gles2/texture.c3
-rw-r--r--render/pixman/renderer.c6
-rw-r--r--render/vulkan/pass.c6
-rw-r--r--render/vulkan/renderer.c6
-rw-r--r--render/vulkan/texture.c3
-rw-r--r--render/wlr_renderer.c2
8 files changed, 20 insertions, 25 deletions
diff --git a/render/egl.c b/render/egl.c
index ea743e9a..8a1e6dae 100644
--- a/render/egl.c
+++ b/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;
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 9fe934f7..4899cfc7 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -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;
}
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 6cfd103d..b444745c 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -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;
diff --git a/render/pixman/renderer.c b/render/pixman/renderer.c
index 1d093024..e30390fa 100644
--- a/render/pixman/renderer.c
+++ b/render/pixman/renderer.c
@@ -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;
}
diff --git a/render/vulkan/pass.c b/render/vulkan/pass.c
index afdcae80..ea7ec42c 100644
--- a/render/vulkan/pass.c
+++ b/render/vulkan/pass.c
@@ -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);
diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c
index d1c3a965..6a0a597c 100644
--- a/render/vulkan/renderer.c
+++ b/render/vulkan/renderer.c
@@ -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);
diff --git a/render/vulkan/texture.c b/render/vulkan/texture.c
index 83a22c81..65ea22ba 100644
--- a/render/vulkan/texture.c
+++ b/render/vulkan/texture.c
@@ -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;
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index 2c05aa43..523079a8 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -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;