s3:dbwrap: add specific dbwrap_wipe() implementation to dbwrap_rbt
authorGregor Beck <gbeck@sernet.de>
Tue, 16 Aug 2011 12:55:30 +0000 (14:55 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 11 Oct 2011 12:17:56 +0000 (14:17 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
source3/lib/dbwrap/dbwrap_rbt.c

index 3b5574a..450e458 100644 (file)
@@ -316,6 +316,19 @@ static int db_rbt_exists(struct db_context *db, TDB_DATA key)
        return db_rbt_search_internal(db, key, NULL);
 }
 
+static int db_rbt_wipe(struct db_context *db)
+{
+       struct db_rbt_ctx *old_ctx = talloc_get_type_abort(
+               db->private_data, struct db_rbt_ctx);
+       struct db_rbt_ctx *new_ctx = TALLOC_ZERO_P(db, struct db_rbt_ctx);
+       if (new_ctx == NULL) {
+               return -1;
+       }
+       db->private_data = new_ctx;
+       talloc_free(old_ctx);
+       return 0;
+}
+
 static int db_rbt_parse_record(struct db_context *db, TDB_DATA key,
                               int (*parser)(TDB_DATA key, TDB_DATA data,
                                             void *private_data),
@@ -433,6 +446,7 @@ struct db_context *db_open_rbt(TALLOC_CTX *mem_ctx)
        result->transaction_commit = db_rbt_trans_dummy;
        result->transaction_cancel = db_rbt_trans_dummy;
        result->exists = db_rbt_exists;
+       result->wipe = db_rbt_wipe;
        result->parse_record = db_rbt_parse_record;
 
        return result;