summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/nine/nine_pdata.h
blob: 7bdd702cfbbd255d9fce49e11ee4b1ba31ed7f89 (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

#ifndef _NINE_PDATA_H_
#define _NINE_PDATA_H_

struct pheader
{
    boolean unknown;
    DWORD size;
    char data[1];
};

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;

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

    return PIPE_OK;
}

#endif /* _NINE_PDATA_H_ */