mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-15 01:32:49 +02:00
7f05c9e284
- jrb.h (struct jrb_node): changed "key" and "val" from "Jval" to "void *" - jrb.h, jval.c (jrb_insert_gen, jrb_find_gen, jrb_find_gte_gen, jrb_val): replaced "Jval" with "void *" or "const void *", respectively - rbtest.c (cmp, INSERT): updated for Jval removal - rbtest.c (main): use jrb_val(jrb) instead of jval_v(jrb->val) - Makefile (OBJS_rbtest): removed jval.o - jval.h, jval.c: removed
38 lines
525 B
C
38 lines
525 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "jrb.h"
|
|
|
|
|
|
|
|
static int cmp(const void *a, const void *b)
|
|
{
|
|
return strcmp(a, b);
|
|
}
|
|
|
|
|
|
#define INSERT(key, val) \
|
|
jrb_insert_gen(tree, key, val, cmp)
|
|
|
|
|
|
int main(void)
|
|
{
|
|
JRB tree = make_jrb();
|
|
JRB p;
|
|
|
|
INSERT("ab", "have");
|
|
INSERT("d", "little");
|
|
INSERT("c", "this");
|
|
INSERT("b", "passed");
|
|
INSERT("e", "regression");
|
|
INSERT("fa", "test");
|
|
INSERT("aa", "We");
|
|
INSERT("ff", "!");
|
|
|
|
jrb_traverse(p, tree)
|
|
printf("%s ", (char *) jrb_val(p));
|
|
printf("\n");
|
|
|
|
return 0;
|
|
}
|