summaryrefslogtreecommitdiff
path: root/lib/dbwrap
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-06-15 10:50:00 +0200
committerStefan Metzmacher <metze@samba.org>2012-06-22 15:16:45 +0200
commitce7b0b9906685740e18c599cb3b453f58c8565d1 (patch)
tree855fe59013dbb5ab13b47f0ae8835f6235916c2d /lib/dbwrap
parent688cda19ba68db8a7557ffe8cbf6e3c79eae74f9 (diff)
downloadsamba-ce7b0b9906685740e18c599cb3b453f58c8565d1.tar.gz
samba-ce7b0b9906685740e18c599cb3b453f58c8565d1.tar.bz2
samba-ce7b0b9906685740e18c599cb3b453f58c8565d1.zip
dbwrap: Add dbwrap_change_int32_atomic
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/dbwrap')
-rw-r--r--lib/dbwrap/dbwrap.h4
-rw-r--r--lib/dbwrap/dbwrap_util.c26
2 files changed, 21 insertions, 9 deletions
diff --git a/lib/dbwrap/dbwrap.h b/lib/dbwrap/dbwrap.h
index 30c24fedb3..6184453812 100644
--- a/lib/dbwrap/dbwrap.h
+++ b/lib/dbwrap/dbwrap.h
@@ -109,6 +109,10 @@ NTSTATUS dbwrap_trans_change_uint32_atomic_bystring(struct db_context *db,
const char *keystr,
uint32_t *oldval,
uint32_t change_val);
+NTSTATUS dbwrap_change_int32_atomic(struct db_context *db,
+ TDB_DATA key,
+ int32_t *oldval,
+ int32_t change_val);
NTSTATUS dbwrap_change_int32_atomic_bystring(struct db_context *db,
const char *keystr,
int32_t *oldval,
diff --git a/lib/dbwrap/dbwrap_util.c b/lib/dbwrap/dbwrap_util.c
index 8e6498d7d0..6086ce90ae 100644
--- a/lib/dbwrap/dbwrap_util.c
+++ b/lib/dbwrap/dbwrap_util.c
@@ -223,7 +223,7 @@ NTSTATUS dbwrap_trans_change_uint32_atomic_bystring(struct db_context *db,
*/
struct dbwrap_change_int32_atomic_context {
- const char *keystr;
+ TDB_DATA key;
int32_t *oldval;
int32_t change_val;
};
@@ -240,8 +240,7 @@ static NTSTATUS dbwrap_change_int32_atomic_action(struct db_context *db,
state = (struct dbwrap_change_int32_atomic_context *)private_data;
- rec = dbwrap_fetch_locked(db, talloc_tos(),
- string_term_tdb_data(state->keystr));
+ rec = dbwrap_fetch_locked(db, talloc_tos(), state->key);
if (!rec) {
return NT_STATUS_UNSUCCESSFUL;
}
@@ -272,15 +271,15 @@ done:
return ret;
}
-NTSTATUS dbwrap_change_int32_atomic_bystring(struct db_context *db,
- const char *keystr,
- int32_t *oldval,
- int32_t change_val)
+NTSTATUS dbwrap_change_int32_atomic(struct db_context *db,
+ TDB_DATA key,
+ int32_t *oldval,
+ int32_t change_val)
{
NTSTATUS ret;
struct dbwrap_change_int32_atomic_context state;
- state.keystr = keystr;
+ state.key = key;
state.oldval = oldval;
state.change_val = change_val;
@@ -289,6 +288,15 @@ NTSTATUS dbwrap_change_int32_atomic_bystring(struct db_context *db,
return ret;
}
+NTSTATUS dbwrap_change_int32_atomic_bystring(struct db_context *db,
+ const char *keystr,
+ int32_t *oldval,
+ int32_t change_val)
+{
+ return dbwrap_change_int32_atomic(db, string_term_tdb_data(keystr),
+ oldval, change_val);
+}
+
NTSTATUS dbwrap_trans_change_int32_atomic_bystring(struct db_context *db,
const char *keystr,
int32_t *oldval,
@@ -297,7 +305,7 @@ NTSTATUS dbwrap_trans_change_int32_atomic_bystring(struct db_context *db,
NTSTATUS ret;
struct dbwrap_change_int32_atomic_context state;
- state.keystr = keystr;
+ state.key = string_term_tdb_data(keystr);
state.oldval = oldval;
state.change_val = change_val;