diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-03-28 01:30:54 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2004-03-28 01:30:54 +0000 |
commit | 4217c609a8c932967aa2641c5e24dde413efb575 (patch) | |
tree | 9a34f4c0c9e906e81376737be66a6cb76536ad92 | |
parent | 83b9f88e26ba00651cdd05e5b30884c8b41b5e0c (diff) | |
download | samba-4217c609a8c932967aa2641c5e24dde413efb575.tar.gz samba-4217c609a8c932967aa2641c5e24dde413efb575.tar.bz2 samba-4217c609a8c932967aa2641c5e24dde413efb575.zip |
removed the state parameter to tdb_traverse and the TDB_MODIFY flag
(This used to be commit 6505efc7e9bfcdae3e370d8557328470608b87ca)
-rw-r--r-- | source4/lib/tdb/tdb.c | 11 | ||||
-rw-r--r-- | source4/lib/tdb/tdb.h | 8 |
2 files changed, 7 insertions, 12 deletions
diff --git a/source4/lib/tdb/tdb.c b/source4/lib/tdb/tdb.c index fc210f42d4..1fef5d54fa 100644 --- a/source4/lib/tdb/tdb.c +++ b/source4/lib/tdb/tdb.c @@ -2,7 +2,6 @@ Unix SMB/CIFS implementation. Samba database functions Copyright (C) Andrew Tridgell 1999-2000 - Copyright (C) Luke Kenneth Casson Leighton 2000 Copyright (C) Paul `Rusty' Russell 2000 Copyright (C) Jeremy Allison 2000-2003 @@ -1293,7 +1292,7 @@ static int tdb_next_lock(TDB_CONTEXT *tdb, struct tdb_traverse_lock *tlock, if fn is NULL then it is not called a non-zero return value from fn() indicates that the traversal should stop */ -int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *state) +int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn) { TDB_DATA key, dbuf; struct list_struct rec; @@ -1331,7 +1330,7 @@ int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *state) ret = -1; goto out; } - if (fn && fn(tdb, key, dbuf, state)) { + if (fn && fn(tdb, key, dbuf)) { /* They want us to terminate traversal */ ret = count; if (unlock_record(tdb, tl.off) != 0) { @@ -1480,8 +1479,6 @@ int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag) /* first try in-place update, on modify or replace. */ if (tdb_update_hash(tdb, key, hash, dbuf) == 0) goto out; - if (flag == TDB_MODIFY && tdb->ecode == TDB_ERR_NOEXIST) - goto fail; } /* reset the error code potentially set by the tdb_update() */ tdb->ecode = TDB_SUCCESS; @@ -1504,9 +1501,7 @@ int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag) if (dbuf.dsize) memcpy(p+key.dsize, dbuf.dptr, dbuf.dsize); - /* now we're into insert / modify / replace of a record which - * we know could not be optimised by an in-place store (for - * various reasons). */ + /* we have to allocate some space */ if (!(rec_ptr = tdb_allocate(tdb, key.dsize + dbuf.dsize, &rec))) goto fail; diff --git a/source4/lib/tdb/tdb.h b/source4/lib/tdb/tdb.h index 720066f1b3..d20f4cd677 100644 --- a/source4/lib/tdb/tdb.h +++ b/source4/lib/tdb/tdb.h @@ -29,7 +29,6 @@ extern "C" { /* flags to tdb_store() */ #define TDB_REPLACE 1 #define TDB_INSERT 2 -#define TDB_MODIFY 3 /* flags for tdb_open() */ #define TDB_DEFAULT 0 /* just a readability place holder */ @@ -44,7 +43,8 @@ extern "C" { /* error codes */ enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, - TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOEXIST, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT }; + TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT, + TDB_ERR_NOEXIST}; #ifndef u32 #define u32 unsigned @@ -98,7 +98,7 @@ typedef struct tdb_context { int open_flags; /* flags used in the open - needed by reopen */ } TDB_CONTEXT; -typedef int (*tdb_traverse_func)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *); +typedef int (*tdb_traverse_func)(TDB_CONTEXT *, TDB_DATA, TDB_DATA); typedef void (*tdb_log_func)(TDB_CONTEXT *, int , const char *, ...); TDB_CONTEXT *tdb_open(const char *name, int hash_size, int tdb_flags, @@ -119,7 +119,7 @@ int tdb_append(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA new_dbuf); int tdb_close(TDB_CONTEXT *tdb); TDB_DATA tdb_firstkey(TDB_CONTEXT *tdb); TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA key); -int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *state); +int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn); int tdb_exists(TDB_CONTEXT *tdb, TDB_DATA key); int tdb_lockkeys(TDB_CONTEXT *tdb, u32 number, TDB_DATA keys[]); void tdb_unlockkeys(TDB_CONTEXT *tdb); |