mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-22 13:19:42 +02:00
qpkg/jrb.c (mk_new_ext): converted from macro to function
This commit is contained in:
parent
009f56c927
commit
5a422a470d
26
qpkg/jrb.c
26
qpkg/jrb.c
@ -94,13 +94,19 @@ static void delete_item(JRB item) /* Deletes an arbitrary iterm */
|
||||
item->blink->flink = item->flink;
|
||||
}
|
||||
|
||||
#define mk_new_ext(new, kkkey, vvval) { \
|
||||
new = (JRB) malloc(sizeof(struct jrb_node)); \
|
||||
new->val = vvval; \
|
||||
new->key = kkkey; \
|
||||
setext(new); \
|
||||
setblack(new); \
|
||||
setnormal(new); \
|
||||
|
||||
static JRB mk_new_ext(void *key, void *val)
|
||||
{
|
||||
JRB new;
|
||||
|
||||
new = (JRB) malloc(sizeof(struct jrb_node));
|
||||
new->val = val;
|
||||
new->key = key;
|
||||
setext(new);
|
||||
setblack(new);
|
||||
setnormal(new);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
static void mk_new_int(JRB l, JRB r, JRB p, int il)
|
||||
@ -230,14 +236,14 @@ static JRB jrb_insert_b(JRB n, void *key, void *val)
|
||||
|
||||
if (ishead(n)) {
|
||||
if (n->parent == n) { /* Tree is empty */
|
||||
mk_new_ext(newnode, key, val);
|
||||
newnode = mk_new_ext(key, val);
|
||||
insert(newnode, n);
|
||||
n->parent = newnode;
|
||||
newnode->parent = n;
|
||||
setroot(newnode);
|
||||
return newnode;
|
||||
} else {
|
||||
mk_new_ext(newright, key, val);
|
||||
newright = mk_new_ext(key, val);
|
||||
insert(newright, n);
|
||||
newleft = newright->blink;
|
||||
setnormal(newleft);
|
||||
@ -249,7 +255,7 @@ static JRB jrb_insert_b(JRB n, void *key, void *val)
|
||||
return newright;
|
||||
}
|
||||
} else {
|
||||
mk_new_ext(newleft, key, val);
|
||||
newleft = mk_new_ext(key, val);
|
||||
insert(newleft, n);
|
||||
setnormal(n);
|
||||
mk_new_int(newleft, n, n->parent, isleft(n));
|
||||
|
Loading…
Reference in New Issue
Block a user