mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-25 21:59:11 +01:00
Use [0] to get element size when allocating arrays
This is clearer than using * or hardcoding a type.
This commit is contained in:
parent
4e11884228
commit
0c65405d54
2 changed files with 4 additions and 4 deletions
4
alloc.c
4
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;
|
||||
|
|
4
layer.c
4
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;
|
||||
|
|
Loading…
Reference in a new issue