diff -r 42085c134e29 -r b53529762874 rb.c --- a/rb.c Wed Mar 10 17:33:39 2004 +0100 +++ b/rb.c Wed Mar 10 17:46:49 2004 +0100 @@ -183,13 +183,13 @@ return rb_find_ikey_n(n, ikey, &fnd); } -Rb_node rb_find_gkey_n(Rb_node n, void *key, Rb_compfn *fxn, int *fnd) +Rb_node rb_find_gkey_n(Rb_node n, const void *key, Rb_compfn *fxn, int *fnd) { int cmp; *fnd = 0; if (!ishead(n)) { - fprintf(stderr, "rb_find_key_n called on non-head %p\n", + fprintf(stderr, "rb_find_gkey_n called on non-head %p\n", DONT_COMPLAIN n); exit(1); } @@ -212,24 +212,40 @@ } } -Rb_node rb_find_gkey(Rb_node n, void *key, Rb_compfn *fxn) +Rb_node rb_find_gkey(Rb_node n, const void *key, Rb_compfn *fxn) { int fnd; return rb_find_gkey_n(n, key, fxn, &fnd); } -Rb_node rb_find_key_n(Rb_node n, char *key, int *fnd) +Rb_node rb_find_key_n(Rb_node n, const char *key, int *fnd) { return rb_find_gkey_n(n, key, (Rb_compfn*)strcmp, fnd); } -Rb_node rb_find_key(Rb_node n, char *key) +Rb_node rb_find_key(Rb_node n, const char *key) { int fnd; return rb_find_gkey_n(n, key, (Rb_compfn*)strcmp, &fnd); } -Rb_node rb_insert_b(Rb_node n, void *key, void *val) +static int ptrcmp(const void *a, const void *b) +{ + return (av.val; } -Rb_node rb_insert_a(Rb_node nd, void *key, void *val) +Rb_node rb_insert_a(Rb_node nd, const void *key, void *val) { return rb_insert_b(nd->c.list.flink, key, val); } -Rb_node rb_insert(Rb_node tree, char *key, void *val) +Rb_node rb_insert(Rb_node tree, const char *key, void *val) { return rb_insert_b(rb_find_key(tree, key), key, val); } @@ -596,9 +612,14 @@ return rb_insert_b(rb_find_ikey(tree, ikey), (void *) ikey, val); } -Rb_node rb_insertg(Rb_node tree, void *key, void *val, Rb_compfn *func) +Rb_node rb_insertg(Rb_node tree, const void *key, void *val, Rb_compfn *func) { return rb_insert_b(rb_find_gkey(tree, key, func), key, val); } +Rb_node rb_insertp(Rb_node tree, const void *key, void *val) +{ + return rb_insertg(tree, key, val, ptrcmp); +} +