freetdm: make conf nodes to be stored in FIFO order
This commit is contained in:
parent
7d84351de9
commit
95cf2209fe
|
@ -268,13 +268,24 @@ FT_DECLARE(ftdm_status_t) ftdm_conf_node_create(const char *name, ftdm_conf_node
|
||||||
if (parent) {
|
if (parent) {
|
||||||
/* store who my parent is */
|
/* store who my parent is */
|
||||||
newnode->parent = parent;
|
newnode->parent = parent;
|
||||||
/* save any siblings */
|
|
||||||
sibling = parent->child;
|
/* arrange them in FIFO order (newnode should be last) */
|
||||||
/* as a newborn I am first */
|
if (!parent->child) {
|
||||||
parent->child = newnode;
|
/* we're the first node being added */
|
||||||
if (sibling) {
|
parent->child = newnode;
|
||||||
/* store a pointer to my next sibling */
|
} else {
|
||||||
newnode->next = sibling;
|
if (!parent->last) {
|
||||||
|
/* we're the second node being added */
|
||||||
|
parent->last = newnode;
|
||||||
|
parent->child->next = newnode;
|
||||||
|
newnode->prev = parent->child;
|
||||||
|
} else {
|
||||||
|
/* we're the third or Nth node to be added */
|
||||||
|
sibling = parent->last;
|
||||||
|
sibling->next = newnode;
|
||||||
|
parent->last = newnode;
|
||||||
|
newnode->prev = sibling;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -322,9 +322,15 @@ struct ftdm_conf_node {
|
||||||
/* first node child */
|
/* first node child */
|
||||||
struct ftdm_conf_node *child;
|
struct ftdm_conf_node *child;
|
||||||
|
|
||||||
|
/* last node child */
|
||||||
|
struct ftdm_conf_node *last;
|
||||||
|
|
||||||
/* next node sibling */
|
/* next node sibling */
|
||||||
struct ftdm_conf_node *next;
|
struct ftdm_conf_node *next;
|
||||||
|
|
||||||
|
/* prev node sibling */
|
||||||
|
struct ftdm_conf_node *prev;
|
||||||
|
|
||||||
/* my parent if any */
|
/* my parent if any */
|
||||||
struct ftdm_conf_node *parent;
|
struct ftdm_conf_node *parent;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue