1
0
mirror of https://gitlab.labs.nic.cz/labs/bird.git synced 2024-05-11 16:54:54 +00:00

Replaced boilerplate eattr allocation by ea_set_attr()

This commit is contained in:
Maria Matejka
2022-04-14 18:32:19 +02:00
parent 1d309c4ce6
commit cf07d8ad79
4 changed files with 40 additions and 102 deletions

View File

@@ -217,10 +217,7 @@ ea_list *ea_normalize(const ea_list *e);
uint ea_list_size(ea_list *);
void ea_list_copy(ea_list *dest, ea_list *src, uint size);
struct ea_one_attr_list {
ea_list l;
eattr a;
};
#define EA_LOCAL_LIST(N) struct { ea_list l; eattr a[N]; }
#define EA_LITERAL_EMBEDDED(_id, _type, _flags, _val) ({ \
ASSERT_DIE(_type & EAF_EMBEDDED); \
@@ -243,16 +240,16 @@ struct ea_one_attr_list {
static inline eattr *
ea_set_attr(ea_list **to, eattr a)
{
struct ea_one_attr_list *ea = tmp_alloc(sizeof(*ea));
*ea = (struct ea_one_attr_list) {
EA_LOCAL_LIST(1) *ea = tmp_alloc(sizeof(*ea));
*ea = (typeof(*ea)) {
.l.flags = EALF_SORTED,
.l.count = 1,
.l.next = *to,
.a = a,
.a[0] = a,
};
*to = &ea->l;
return &ea->a;
return &ea->a[0];
}
static inline void