summaryrefslogtreecommitdiff
path: root/source3/tdb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/tdb')
-rw-r--r--source3/tdb/tdb.c12
-rw-r--r--source3/tdb/tdb.h4
-rw-r--r--source3/tdb/tdbutil.c2
3 files changed, 7 insertions, 11 deletions
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index 0ebbc8b21e..9a059d459e 100644
--- a/source3/tdb/tdb.c
+++ b/source3/tdb/tdb.c
@@ -1689,11 +1689,6 @@ static u32 default_tdb_hash(TDB_DATA *key)
return (1103515243 * value + 12345);
}
-void tdb_set_hash_function(TDB_CONTEXT *tdb, tdb_hash_func fn)
-{
- tdb->hash_fn = fn;
-}
-
/* open the database, creating it if necessary
The open_flags and mode are passed straight to the open call on the
@@ -1707,13 +1702,14 @@ void tdb_set_hash_function(TDB_CONTEXT *tdb, tdb_hash_func fn)
TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode)
{
- return tdb_open_ex(name, hash_size, tdb_flags, open_flags, mode, NULL);
+ return tdb_open_ex(name, hash_size, tdb_flags, open_flags, mode, NULL, NULL);
}
TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode,
- tdb_log_func log_fn)
+ tdb_log_func log_fn,
+ tdb_hash_func hash_fn)
{
TDB_CONTEXT *tdb;
struct stat st;
@@ -1733,7 +1729,7 @@ TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
tdb->flags = tdb_flags;
tdb->open_flags = open_flags;
tdb->log_fn = log_fn;
- tdb->hash_fn = default_tdb_hash;
+ tdb->hash_fn = hash_fn ? hash_fn : default_tdb_hash;
if ((open_flags & O_ACCMODE) == O_WRONLY) {
TDB_LOG((tdb, 0, "tdb_open_ex: can't open tdb %s write-only\n",
diff --git a/source3/tdb/tdb.h b/source3/tdb/tdb.h
index 8f4421d8fa..c28e10af69 100644
--- a/source3/tdb/tdb.h
+++ b/source3/tdb/tdb.h
@@ -114,12 +114,12 @@ TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode);
TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
int open_flags, mode_t mode,
- tdb_log_func log_fn);
+ tdb_log_func log_fn,
+ tdb_hash_func hash_fn);
int tdb_reopen(TDB_CONTEXT *tdb);
int tdb_reopen_all(void);
void tdb_logging_function(TDB_CONTEXT *tdb, tdb_log_func);
-void tdb_set_hash_function(TDB_CONTEXT *tdb, tdb_hash_func);
enum TDB_ERROR tdb_error(TDB_CONTEXT *tdb);
const char *tdb_errorstr(TDB_CONTEXT *tdb);
TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key);
diff --git a/source3/tdb/tdbutil.c b/source3/tdb/tdbutil.c
index 09e55e2e70..e57eccfe59 100644
--- a/source3/tdb/tdbutil.c
+++ b/source3/tdb/tdbutil.c
@@ -740,7 +740,7 @@ TDB_CONTEXT *tdb_open_log(const char *name, int hash_size, int tdb_flags,
tdb_flags |= TDB_NOMMAP;
tdb = tdb_open_ex(name, hash_size, tdb_flags,
- open_flags, mode, tdb_log);
+ open_flags, mode, tdb_log, NULL);
if (!tdb)
return NULL;