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

« back to all changes in this revision

Viewing changes to libdb/hash/hash_method.c

  • 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) 1999-2002
5
 
 *      Sleepycat Software.  All rights reserved.
6
 
 */
7
 
 
8
 
#include "db_config.h"
9
 
 
10
 
#ifndef lint
11
 
static const char revid[] = "$Id$";
12
 
#endif /* not lint */
13
 
 
14
 
#ifndef NO_SYSTEM_INCLUDES
15
 
#include <sys/types.h>
16
 
#endif
17
 
 
18
 
#include "db_int.h"
19
 
#include "dbinc/db_page.h"
20
 
#include "dbinc/hash.h"
21
 
 
22
 
static int __ham_set_h_ffactor __P((DB *, u_int32_t));
23
 
static int __ham_set_h_hash
24
 
               __P((DB *, u_int32_t(*)(DB *, const void *, u_int32_t)));
25
 
static int __ham_set_h_nelem __P((DB *, u_int32_t));
26
 
 
27
 
/*
28
 
 * __ham_db_create --
29
 
 *      Hash specific initialization of the DB structure.
30
 
 *
31
 
 * PUBLIC: int __ham_db_create __P((DB *));
32
 
 */
33
 
int
34
 
__ham_db_create(dbp)
35
 
        DB *dbp;
36
 
{
37
 
        HASH *hashp;
38
 
        int ret;
39
 
 
40
 
        if ((ret = __os_malloc(dbp->dbenv,
41
 
            sizeof(HASH), &dbp->h_internal)) != 0)
42
 
                return (ret);
43
 
 
44
 
        hashp = dbp->h_internal;
45
 
 
46
 
        hashp->h_nelem = 0;                     /* Defaults. */
47
 
        hashp->h_ffactor = 0;
48
 
        hashp->h_hash = NULL;
49
 
 
50
 
        dbp->set_h_ffactor = __ham_set_h_ffactor;
51
 
        dbp->set_h_hash = __ham_set_h_hash;
52
 
        dbp->set_h_nelem = __ham_set_h_nelem;
53
 
 
54
 
        return (0);
55
 
}
56
 
 
57
 
/*
58
 
 * PUBLIC: int __ham_db_close __P((DB *));
59
 
 */
60
 
int
61
 
__ham_db_close(dbp)
62
 
        DB *dbp;
63
 
{
64
 
        if (dbp->h_internal == NULL)
65
 
                return (0);
66
 
        __os_free(dbp->dbenv, dbp->h_internal);
67
 
        dbp->h_internal = NULL;
68
 
        return (0);
69
 
}
70
 
 
71
 
/*
72
 
 * __ham_set_h_ffactor --
73
 
 *      Set the fill factor.
74
 
 */
75
 
static int
76
 
__ham_set_h_ffactor(dbp, h_ffactor)
77
 
        DB *dbp;
78
 
        u_int32_t h_ffactor;
79
 
{
80
 
        HASH *hashp;
81
 
 
82
 
        DB_ILLEGAL_AFTER_OPEN(dbp, "set_h_ffactor");
83
 
        DB_ILLEGAL_METHOD(dbp, DB_OK_HASH);
84
 
 
85
 
        hashp = dbp->h_internal;
86
 
        hashp->h_ffactor = h_ffactor;
87
 
        return (0);
88
 
}
89
 
 
90
 
/*
91
 
 * __ham_set_h_hash --
92
 
 *      Set the hash function.
93
 
 */
94
 
static int
95
 
__ham_set_h_hash(dbp, func)
96
 
        DB *dbp;
97
 
        u_int32_t (*func) __P((DB *, const void *, u_int32_t));
98
 
{
99
 
        HASH *hashp;
100
 
 
101
 
        DB_ILLEGAL_AFTER_OPEN(dbp, "set_h_hash");
102
 
        DB_ILLEGAL_METHOD(dbp, DB_OK_HASH);
103
 
 
104
 
        hashp = dbp->h_internal;
105
 
        hashp->h_hash = func;
106
 
        return (0);
107
 
}
108
 
 
109
 
/*
110
 
 * __ham_set_h_nelem --
111
 
 *      Set the table size.
112
 
 */
113
 
static int
114
 
__ham_set_h_nelem(dbp, h_nelem)
115
 
        DB *dbp;
116
 
        u_int32_t h_nelem;
117
 
{
118
 
        HASH *hashp;
119
 
 
120
 
        DB_ILLEGAL_AFTER_OPEN(dbp, "set_h_nelem");
121
 
        DB_ILLEGAL_METHOD(dbp, DB_OK_HASH);
122
 
 
123
 
        hashp = dbp->h_internal;
124
 
        hashp->h_nelem = h_nelem;
125
 
        return (0);
126
 
}