mirror of https://github.com/schoebel/mars
infra: round up input_size to even sizes and addresses
This commit is contained in:
parent
bd3fa16b64
commit
598cfc9d67
|
@ -201,6 +201,7 @@ int generic_brick_init_full(
|
|||
for (i = 0; i < brick_type->max_inputs; i++) {
|
||||
struct generic_input *input = data;
|
||||
const struct generic_input_type *type = *input_types++;
|
||||
int input_size;
|
||||
|
||||
if (!type || type->input_size <= 0) {
|
||||
return -EINVAL;
|
||||
|
@ -209,8 +210,11 @@ int generic_brick_init_full(
|
|||
status = generic_input_init(brick, i, type, input, (names && *names) ? *names++ : type->type_name);
|
||||
if (status < 0)
|
||||
return status;
|
||||
data += type->input_size;
|
||||
size -= type->input_size;
|
||||
input_size = type->input_size;
|
||||
input_size = DIV_ROUND_UP(input_size,
|
||||
sizeof(void *)) * sizeof(void *);
|
||||
data += input_size;
|
||||
size -= input_size;
|
||||
if (size < 0)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
|
@ -561,7 +561,11 @@ INLINE int generic_size(const struct generic_brick_type *brick_type)
|
|||
size = DIV_ROUND_UP(size, sizeof(void *)) * sizeof(void *);
|
||||
size += brick_type->max_inputs * sizeof(void*);
|
||||
for (i = 0; i < brick_type->max_inputs; i++) {
|
||||
size += brick_type->default_input_types[i]->input_size;
|
||||
int input_size = brick_type->default_input_types[i]->input_size;
|
||||
|
||||
input_size = DIV_ROUND_UP(input_size,
|
||||
sizeof(void *)) * sizeof(void *);
|
||||
size += input_size;
|
||||
}
|
||||
size += brick_type->max_outputs * sizeof(void*);
|
||||
for (i = 0; i < brick_type->max_outputs; i++) {
|
||||
|
|
|
@ -2849,15 +2849,20 @@ struct mars_brick *mars_make_brick(struct mars_global *global, struct mars_dent
|
|||
input_types = brick_type->default_input_types;
|
||||
for (i = 0; i < brick_type->max_inputs; i++) {
|
||||
const struct generic_input_type *type = *input_types++;
|
||||
int input_size;
|
||||
|
||||
if (unlikely(!type)) {
|
||||
MARS_ERR("input_type %d is missing\n", i);
|
||||
goto err_name;
|
||||
}
|
||||
if (unlikely(type->input_size <= 0)) {
|
||||
input_size = type->input_size;
|
||||
if (unlikely(input_size <= 0)) {
|
||||
MARS_ERR("bad input_size at %d\n", i);
|
||||
goto err_name;
|
||||
}
|
||||
size += type->input_size;
|
||||
input_size = DIV_ROUND_UP(input_size,
|
||||
sizeof(void *)) * sizeof(void *);
|
||||
size += input_size;
|
||||
}
|
||||
output_types = brick_type->default_output_types;
|
||||
for (i = 0; i < brick_type->max_outputs; i++) {
|
||||
|
|
Loading…
Reference in New Issue