~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/dbinc/db_shash.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-
2
 
 * See the file LICENSE for redistribution information.
3
 
 *
4
 
 * Copyright (c) 1996-2002
5
 
 *      Sleepycat Software.  All rights reserved.
6
 
 *
7
 
 * $Id$
8
 
 */
9
 
 
10
 
#ifndef _DB_SHASH_H_
11
 
#define _DB_SHASH_H_
12
 
 
13
 
/* Hash Headers */
14
 
typedef SH_TAILQ_HEAD(__hash_head) DB_HASHTAB;
15
 
 
16
 
/*
17
 
 * HASHLOOKUP --
18
 
 *
19
 
 * Look up something in a shared memory hash table.  The "elt" argument
20
 
 * should be a key, and cmp_func must know how to compare a key to whatever
21
 
 * structure it is that appears in the hash table.  The comparison function
22
 
 *
23
 
 * begin: address of the beginning of the hash table.
24
 
 * ndx:   index into table for this item.
25
 
 * type:  the structure type of the elements that are linked in each bucket.
26
 
 * field: the name of the field by which the "type" structures are linked.
27
 
 * elt:   the item for which we are searching in the hash table.
28
 
 * res:   the variable into which we'll store the element if we find it.
29
 
 * cmp:   called as: cmp(lookup_elt, table_elt).
30
 
 *
31
 
 * If the element is not in the hash table, this macro exits with res set
32
 
 * to NULL.
33
 
 */
34
 
#define HASHLOOKUP(begin, ndx, type, field, elt, res, cmp) do {         \
35
 
        DB_HASHTAB *__bucket;                                           \
36
 
                                                                        \
37
 
        __bucket = &begin[ndx];                                         \
38
 
        for (res = SH_TAILQ_FIRST(__bucket, type);                      \
39
 
            res != NULL; res = SH_TAILQ_NEXT(res, field, type))         \
40
 
                if (cmp(elt, res))                                      \
41
 
                        break;                                          \
42
 
} while (0)
43
 
 
44
 
/*
45
 
 * HASHINSERT --
46
 
 *
47
 
 * Insert a new entry into the hash table.  This assumes that you already
48
 
 * have the bucket locked and that lookup has failed; don't call it if you
49
 
 * haven't already called HASHLOOKUP.  If you do, you could get duplicate
50
 
 * entries.
51
 
 *
52
 
 * begin: the beginning address of the hash table.
53
 
 * ndx:   the index for this element.
54
 
 * type:  the structure type of the elements that are linked in each bucket.
55
 
 * field: the name of the field by which the "type" structures are linked.
56
 
 * elt:   the item to be inserted.
57
 
 */
58
 
#define HASHINSERT(begin, ndx, type, field, elt) do {                   \
59
 
        DB_HASHTAB *__bucket;                                           \
60
 
                                                                        \
61
 
        __bucket = &begin[ndx];                                         \
62
 
        SH_TAILQ_INSERT_HEAD(__bucket, elt, field, type);               \
63
 
} while (0)
64
 
 
65
 
/*
66
 
 * HASHREMOVE_EL --
67
 
 *      Given the object "obj" in the table, remove it.
68
 
 *
69
 
 * begin: address of the beginning of the hash table.
70
 
 * ndx:   index into hash table of where this element belongs.
71
 
 * type:  the structure type of the elements that are linked in each bucket.
72
 
 * field: the name of the field by which the "type" structures are linked.
73
 
 * obj:   the object in the table that we with to delete.
74
 
 */
75
 
#define HASHREMOVE_EL(begin, ndx, type, field, obj) {                   \
76
 
        DB_HASHTAB *__bucket;                                           \
77
 
                                                                        \
78
 
        __bucket = &begin[ndx];                                         \
79
 
        SH_TAILQ_REMOVE(__bucket, obj, field, type);                    \
80
 
}
81
 
#endif /* !_DB_SHASH_H_ */