mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
Merge branch 'master' into int-new-channels
This commit is contained in:
29
lib/lists.c
29
lib/lists.c
@@ -41,7 +41,7 @@ add_tail(list *l, node *n)
|
||||
{
|
||||
node *z = l->tail;
|
||||
|
||||
n->next = (node *) &l->null;
|
||||
n->next = &l->tail_node;
|
||||
n->prev = z;
|
||||
z->next = n;
|
||||
l->tail = n;
|
||||
@@ -60,7 +60,7 @@ add_head(list *l, node *n)
|
||||
node *z = l->head;
|
||||
|
||||
n->next = z;
|
||||
n->prev = (node *) &l->head;
|
||||
n->prev = &l->head_node;
|
||||
z->prev = n;
|
||||
l->head = n;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ insert_node(node *n, node *after)
|
||||
* rem_node - remove a node from a list
|
||||
* @n: node to be removed
|
||||
*
|
||||
* Removes a node @n from the list it's linked in.
|
||||
* Removes a node @n from the list it's linked in. Afterwards, node @n is cleared.
|
||||
*/
|
||||
LIST_INLINE void
|
||||
rem_node(node *n)
|
||||
@@ -96,23 +96,6 @@ rem_node(node *n)
|
||||
node *z = n->prev;
|
||||
node *x = n->next;
|
||||
|
||||
z->next = x;
|
||||
x->prev = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* rem2_node - remove a node from a list, with cleanup
|
||||
* @n: node to be removed
|
||||
*
|
||||
* Removes a node @n from the list it's linked in and resets its pointers to NULL.
|
||||
* Useful if you want to distinguish between linked and unlinked nodes.
|
||||
*/
|
||||
LIST_INLINE void
|
||||
rem2_node(node *n)
|
||||
{
|
||||
node *z = n->prev;
|
||||
node *x = n->next;
|
||||
|
||||
z->next = x;
|
||||
x->prev = z;
|
||||
n->next = NULL;
|
||||
@@ -150,9 +133,9 @@ replace_node(node *old, node *new)
|
||||
LIST_INLINE void
|
||||
init_list(list *l)
|
||||
{
|
||||
l->head = (node *) &l->null;
|
||||
l->head = &l->tail_node;
|
||||
l->null = NULL;
|
||||
l->tail = (node *) &l->head;
|
||||
l->tail = &l->head_node;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,6 +155,6 @@ add_tail_list(list *to, list *l)
|
||||
p->next = q;
|
||||
q->prev = p;
|
||||
q = l->tail;
|
||||
q->next = (node *) &to->null;
|
||||
q->next = &to->tail_node;
|
||||
to->tail = q;
|
||||
}
|
||||
|
||||
18
lib/lists.h
18
lib/lists.h
@@ -26,10 +26,23 @@ typedef struct node {
|
||||
struct node *next, *prev;
|
||||
} node;
|
||||
|
||||
typedef struct list { /* In fact two overlayed nodes */
|
||||
struct node *head, *null, *tail;
|
||||
typedef union list { /* In fact two overlayed nodes */
|
||||
struct { /* Head node */
|
||||
struct node head_node;
|
||||
void *head_padding;
|
||||
};
|
||||
struct { /* Tail node */
|
||||
void *tail_padding;
|
||||
struct node tail_node;
|
||||
};
|
||||
struct { /* Split to separate pointers */
|
||||
struct node *head;
|
||||
struct node *null;
|
||||
struct node *tail;
|
||||
};
|
||||
} list;
|
||||
|
||||
|
||||
#define NODE (node *)
|
||||
#define HEAD(list) ((void *)((list).head))
|
||||
#define TAIL(list) ((void *)((list).tail))
|
||||
@@ -64,7 +77,6 @@ typedef struct list { /* In fact two overlayed nodes */
|
||||
void add_tail(list *, node *);
|
||||
void add_head(list *, node *);
|
||||
void rem_node(node *);
|
||||
void rem2_node(node *);
|
||||
void add_tail_list(list *, list *);
|
||||
void init_list(list *);
|
||||
void insert_node(node *, node *);
|
||||
|
||||
@@ -163,6 +163,7 @@ rfree(void *res)
|
||||
if (r->n.next)
|
||||
rem_node(&r->n);
|
||||
r->class->free(r);
|
||||
r->class = NULL;
|
||||
xfree(r);
|
||||
}
|
||||
|
||||
@@ -383,16 +384,9 @@ mb_allocz(pool *p, unsigned size)
|
||||
void *
|
||||
mb_realloc(void *m, unsigned size)
|
||||
{
|
||||
struct mblock *ob = NULL;
|
||||
struct mblock *b = SKIP_BACK(struct mblock, data, m);
|
||||
|
||||
if (m)
|
||||
{
|
||||
ob = SKIP_BACK(struct mblock, data, m);
|
||||
if (ob->r.n.next)
|
||||
rem_node(&ob->r.n);
|
||||
}
|
||||
|
||||
struct mblock *b = xrealloc(ob, sizeof(struct mblock) + size);
|
||||
b = xrealloc(b, sizeof(struct mblock) + size);
|
||||
replace_node(&b->r.n, &b->r.n);
|
||||
b->size = size;
|
||||
return b->data;
|
||||
|
||||
@@ -27,6 +27,7 @@ typedef struct birdsock {
|
||||
struct iface *iface; /* Interface; specify this for broad/multicast sockets */
|
||||
|
||||
byte *rbuf, *rpos; /* NULL=allocate automatically */
|
||||
uint fast_rx; /* RX has higher priority in event loop */
|
||||
uint rbsize;
|
||||
int (*rx_hook)(struct birdsock *, int size); /* NULL=receiving turned off, returns 1 to clear rx buffer */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user