From 0c65405d547adcdff241959956ca909973ce196a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 15 May 2024 12:00:31 +0200 Subject: [PATCH] Use [0] to get element size when allocating arrays This is clearer than using * or hardcoding a type. --- alloc.c | 4 ++-- layer.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/alloc.c b/alloc.c index cdeb926..0f06333 100644 --- a/alloc.c +++ b/alloc.c @@ -947,8 +947,8 @@ liftoff_output_apply(struct liftoff_output *output, drmModeAtomicReq *req, result.flags = flags; result.planes_len = liftoff_list_length(&device->planes); - step.alloc = malloc(result.planes_len * sizeof(*step.alloc)); - result.best = malloc(result.planes_len * sizeof(*result.best)); + step.alloc = malloc(result.planes_len * sizeof(step.alloc[0])); + result.best = malloc(result.planes_len * sizeof(result.best[0])); if (step.alloc == NULL || result.best == NULL) { liftoff_log_errno(LIFTOFF_ERROR, "malloc"); return -ENOMEM; diff --git a/layer.c b/layer.c index 5ac06c5..4c45dfd 100644 --- a/layer.c +++ b/layer.c @@ -77,8 +77,8 @@ liftoff_layer_set_property(struct liftoff_layer *layer, const char *name, prop = layer_get_property(layer, name); if (prop == NULL) { - props = realloc(layer->props, (layer->props_len + 1) - * sizeof(struct liftoff_layer_property)); + props = realloc(layer->props, + (layer->props_len + 1) * sizeof(props[0])); if (props == NULL) { liftoff_log_errno(LIFTOFF_ERROR, "realloc"); return -ENOMEM;