mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-26 21:59:18 +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.flags = flags;
|
||||||
result.planes_len = liftoff_list_length(&device->planes);
|
result.planes_len = liftoff_list_length(&device->planes);
|
||||||
|
|
||||||
step.alloc = malloc(result.planes_len * sizeof(*step.alloc));
|
step.alloc = malloc(result.planes_len * sizeof(step.alloc[0]));
|
||||||
result.best = malloc(result.planes_len * sizeof(*result.best));
|
result.best = malloc(result.planes_len * sizeof(result.best[0]));
|
||||||
if (step.alloc == NULL || result.best == NULL) {
|
if (step.alloc == NULL || result.best == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "malloc");
|
liftoff_log_errno(LIFTOFF_ERROR, "malloc");
|
||||||
return -ENOMEM;
|
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);
|
prop = layer_get_property(layer, name);
|
||||||
if (prop == NULL) {
|
if (prop == NULL) {
|
||||||
props = realloc(layer->props, (layer->props_len + 1)
|
props = realloc(layer->props,
|
||||||
* sizeof(struct liftoff_layer_property));
|
(layer->props_len + 1) * sizeof(props[0]));
|
||||||
if (props == NULL) {
|
if (props == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "realloc");
|
liftoff_log_errno(LIFTOFF_ERROR, "realloc");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
Loading…
Reference in a new issue