summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/nine/nine_pdata.h
blob: 92e50c8a72ce4a0ef79fc2afc537d3129bfa88db (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

#ifndef _NINE_PDATA_H_
#define _NINE_PDATA_H_

struct pheader
{
    boolean unknown;
    GUID guid;
    DWORD size;
};

static int
ht_guid_compare( void *a,
                 void *b )
{
    return GUID_equal(a, b) ? 0 : 1;
}

static unsigned
ht_guid_hash( void *key )
{
    unsigned i, hash = 0;
    const unsigned char *str = key;

    for (i = 0; i < sizeof(GUID); i++) {
        hash = (unsigned)(str[i]) + (hash << 6) + (hash << 16) - hash;
    }

    return hash;
}

static enum pipe_error
ht_guid_delete( void *key,
                void *value,
                void *data )
{
    struct pheader *header = value;
    void *header_data = (void *)header + sizeof(*header);

    if (header->unknown) { IUnknown_Release(*(IUnknown **)header_data); }
    FREE(header);

    return PIPE_OK;
}

#endif /* _NINE_PDATA_H_ */