aboutsummaryrefslogtreecommitdiff
path: root/tests/test38.c
blob: dc9dae94e54890b9363d09508a6b23dc594fac28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "uthash.h"
#include <stdlib.h>
#include <stdio.h>

struct test_t {
    int a;
    UT_hash_handle hh;
};

int main()
{
    struct test_t *tests=NULL, *test;
    int a, b;
    for (b=0; b < 3; b++) {
        for (a=0; a < 10; a++) {
            test = NULL;
            HASH_FIND(hh, tests, &a, sizeof(a), test);
            if (test == NULL) {
                test = (struct test_t*)malloc(sizeof(struct test_t));
                if (test == NULL) {
                    exit(-1);
                }
                memset(test, 0, sizeof(struct test_t));
                test->a = a;
                HASH_ADD(hh, tests, a, sizeof(a), test);
            }
        }
    }
    printf("hash count %u\n", HASH_COUNT(tests));
    return 0;
}