9 RB_ENTRY(mist
) rbentry
;
12 RB_HEAD(head
, mist
) tt
;
15 mistcmp(struct mist
*a
, struct mist
*b
)
18 return (b
->key
- a
->key
); /* wrong, can overflow */
22 else if (b
->key
< a
->key
)
29 RB_PROTOTYPE(head
, mist
, rbentry
, mistcmp
)
30 RB_GENERATE(head
, mist
, rbentry
, mistcmp
)
37 m
= malloc(sizeof(struct mist
));
39 RB_INSERT(head
, &tt
, m
);
44 findmist(struct mist
*m
)
47 return (!!RB_FIND(head
, &tt
, m
));
59 for (i
= 0; i
< N
; i
++) {
60 m
[i
] = addmist(random() << 1); /* use all 32 bits */
61 for (j
= 0; j
<= i
; j
++)
69 main(int argc
, char **argv
)
75 for (i
= 0; i
< 10; i
++) {
78 printf("loop %d: %d errors\n", i
, f
);