8 xhash_t *my_resize(xhash_t *h, ul_t sizeshift)
10 ssize_t bytes = xhash_get_alloc_size(sizeshift);
11 xhash_t *new = malloc(bytes);
16 xhash_resize(h, sizeshift, new);
22 int main(int argc, char **argv) {
28 loops = atoi(argv[1]);
33 h = malloc(xhash_get_alloc_size(2));
39 for (i = 10; i < loops; i++) {
42 //printf("insert(%lx, %lx)\n", i, -i);
43 rr = xhash_insert(h, i, -i);
44 if (rr == -XHASH_ERESIZE){
45 h = my_resize(h, grow_size_shift(h));
46 rr = xhash_insert(h, i, -i);
48 printf("resize insert error in %lx: %lx != %lx\n", i, r, -i);
50 ret = xhash_lookup(h, i, &r);
51 if (ret || (r != -i)) {
52 printf("insert error in %lx: %lx != %lx\n", i, r, -i);
54 //printf(" ->got(%lx, %lx)\n", i, r);
56 for (i = 10; i < loops; i++) {
57 int ret = xhash_lookup(h, i, &v);
58 //printf(" ->got(%lu, %lu)\n", i, v);
59 if (ret || (i != -v)) {
60 printf("error in %lu: %lu != %lu\n", i, i, -v);
64 for (i = 10; i < loops; i++) {
67 //printf("insert(%lx, %lx)\n", i, -i);
68 rr = xhash_delete(h, i);
69 if (rr == -XHASH_ERESIZE){
70 h = my_resize(h, shrink_size_shift(h));
71 rr = xhash_delete(h, i);
73 printf("resize delele error in %lx: %lx != %lx\n", i, r, -i);
75 ret = xhash_lookup(h, i, &r);
77 printf("delete error in %lx: %lx != %lx\n", i, r, -i);
79 //printf(" ->got(%lx, %lx)\n", i, r);
83 printf("test completed successfully\n");