summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-03-09 11:15:10 +0100
committerVolker Lendecke <vl@samba.org>2008-03-10 21:08:44 +0100
commit69d67122b2935ce4e7691a9480444edecac1ab8c (patch)
treeb316f912038f45d42833ee24c6173a2dfe840225 /source3/lib
parent0c10ab5cc3144fd7f2082c3b0a7f0e0b7f9bfca6 (diff)
downloadsamba-69d67122b2935ce4e7691a9480444edecac1ab8c.tar.gz
samba-69d67122b2935ce4e7691a9480444edecac1ab8c.tar.bz2
samba-69d67122b2935ce4e7691a9480444edecac1ab8c.zip
add dbwrap_change_int32_atomic
(This used to be commit 4ee21a98bc3d1c41a6d8868e98118c58372b2d1a)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap_util.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c
index 002d572019..ba1f6ae96e 100644
--- a/source3/lib/dbwrap_util.c
+++ b/source3/lib/dbwrap_util.c
@@ -88,3 +88,31 @@ uint32_t dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
return 0;
}
+int32 dbwrap_change_int32_atomic(struct db_context *db, const char *keystr,
+ int32 *oldval, int32 change_val)
+{
+ struct db_record *rec;
+ int32 val = -1;
+ TDB_DATA data;
+
+ if (!(rec = db->fetch_locked(db, NULL,
+ string_term_tdb_data(keystr)))) {
+ return -1;
+ }
+
+ if ((rec->value.dptr != NULL)
+ && (rec->value.dsize == sizeof(val))) {
+ val = IVAL(rec->value.dptr, 0);
+ }
+
+ val += change_val;
+
+ data.dsize = sizeof(val);
+ data.dptr = (uint8 *)&val;
+
+ rec->store(rec, data, TDB_REPLACE);
+
+ TALLOC_FREE(rec);
+
+ return 0;
+}