1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-22 18:28:07 +02:00

qpkg/jrb.c (mk_new_ext): converted from macro to function

This commit is contained in:
Werner Almesberger 2010-11-19 20:23:16 -03:00
parent 009f56c927
commit 5a422a470d

View File

@ -94,13 +94,19 @@ static void delete_item(JRB item) /* Deletes an arbitrary iterm */
item->blink->flink = item->flink; item->blink->flink = item->flink;
} }
#define mk_new_ext(new, kkkey, vvval) { \
new = (JRB) malloc(sizeof(struct jrb_node)); \ static JRB mk_new_ext(void *key, void *val)
new->val = vvval; \ {
new->key = kkkey; \ JRB new;
setext(new); \
setblack(new); \ new = (JRB) malloc(sizeof(struct jrb_node));
setnormal(new); \ 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) 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 (ishead(n)) {
if (n->parent == n) { /* Tree is empty */ if (n->parent == n) { /* Tree is empty */
mk_new_ext(newnode, key, val); newnode = mk_new_ext(key, val);
insert(newnode, n); insert(newnode, n);
n->parent = newnode; n->parent = newnode;
newnode->parent = n; newnode->parent = n;
setroot(newnode); setroot(newnode);
return newnode; return newnode;
} else { } else {
mk_new_ext(newright, key, val); newright = mk_new_ext(key, val);
insert(newright, n); insert(newright, n);
newleft = newright->blink; newleft = newright->blink;
setnormal(newleft); setnormal(newleft);
@ -249,7 +255,7 @@ static JRB jrb_insert_b(JRB n, void *key, void *val)
return newright; return newright;
} }
} else { } else {
mk_new_ext(newleft, key, val); newleft = mk_new_ext(key, val);
insert(newleft, n); insert(newleft, n);
setnormal(n); setnormal(n);
mk_new_int(newleft, n, n->parent, isleft(n)); mk_new_int(newleft, n, n->parent, isleft(n));