Browse Source

tdb2: unify tdb1_wipe into tdb_wipe.

Switch on the TDB_VERSION1 flag.
Rusty Russell 14 years ago
parent
commit
b2555a868e
3 changed files with 7 additions and 2 deletions
  1. 1 0
      ccan/tdb2/private.h
  2. 0 2
      ccan/tdb2/tdb1.h
  3. 6 0
      ccan/tdb2/traverse.c

+ 1 - 0
ccan/tdb2/private.h

@@ -681,6 +681,7 @@ enum TDB_ERROR tdb1_parse_record(struct tdb_context *tdb, TDB_DATA key,
 				 void *private_data);
 				 void *private_data);
 void tdb1_increment_seqnum_nonblock(struct tdb_context *tdb);
 void tdb1_increment_seqnum_nonblock(struct tdb_context *tdb);
 int tdb1_get_seqnum(struct tdb_context *tdb);
 int tdb1_get_seqnum(struct tdb_context *tdb);
+int tdb1_wipe_all(struct tdb_context *tdb);
 
 
 /* tdb1_transaction.c: */
 /* tdb1_transaction.c: */
 int tdb1_transaction_start(struct tdb_context *tdb);
 int tdb1_transaction_start(struct tdb_context *tdb);

+ 0 - 2
ccan/tdb2/tdb1.h

@@ -42,8 +42,6 @@ uint64_t tdb1_incompatible_hash(const void *key, size_t len, uint64_t seed, void
 
 
 /* @} ******************************************************************/
 /* @} ******************************************************************/
 
 
-/* wipe and repack */
-int tdb1_wipe_all(struct tdb_context *tdb);
 int tdb1_repack(struct tdb_context *tdb);
 int tdb1_repack(struct tdb_context *tdb);
 
 
 extern TDB_DATA tdb1_null;
 extern TDB_DATA tdb1_null;

+ 6 - 0
ccan/tdb2/traverse.c

@@ -115,6 +115,12 @@ enum TDB_ERROR tdb_wipe_all(struct tdb_context *tdb)
 	enum TDB_ERROR ecode;
 	enum TDB_ERROR ecode;
 	int64_t count;
 	int64_t count;
 
 
+	if (tdb->flags & TDB_VERSION1) {
+		if (tdb1_wipe_all(tdb) == -1)
+			return tdb->last_error;
+		return TDB_SUCCESS;
+	}
+
 	ecode = tdb_allrecord_lock(tdb, F_WRLCK, TDB_LOCK_WAIT, false);
 	ecode = tdb_allrecord_lock(tdb, F_WRLCK, TDB_LOCK_WAIT, false);
 	if (ecode != TDB_SUCCESS)
 	if (ecode != TDB_SUCCESS)
 		return tdb->last_error = ecode;
 		return tdb->last_error = ecode;