X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/28052481c1892cd06a2626a1ecd7221c3814f0e6..a047e3e158d560af079bec920460711d8222317c:/keydb_db4.c?ds=sidebyside diff --git a/keydb_db4.c b/keydb_db4.c index 04949d0..0d7b46b 100644 --- a/keydb_db4.c +++ b/keydb_db4.c @@ -6,7 +6,6 @@ * Copyright 2002-2004 Project Purple */ -#include #include #include #include @@ -225,17 +224,25 @@ void cleanupdb(void) { int i = 0; - dbenv->txn_checkpoint(dbenv, 0, 0, 0); - id32db->close(id32db, 0); - id32db = NULL; - worddb->close(worddb, 0); - worddb = NULL; - for (i = 0; i < numdbs; i++) { - dbconns[i]->close(dbconns[i], 0); - dbconns[i] = NULL; + if (dbenv != NULL) { + dbenv->txn_checkpoint(dbenv, 0, 0, 0); + if (id32db != NULL) { + id32db->close(id32db, 0); + id32db = NULL; + } + if (worddb != NULL) { + worddb->close(worddb, 0); + worddb = NULL; + } + for (i = 0; i < numdbs; i++) { + if (dbconns[i] != NULL) { + dbconns[i]->close(dbconns[i], 0); + dbconns[i] = NULL; + } + } + dbenv->close(dbenv, 0); + dbenv = NULL; } - dbenv->close(dbenv, 0); - dbenv = NULL; } /** @@ -249,8 +256,8 @@ bool starttrans(void) { int ret; - assert(dbenv != NULL); - assert(txn == NULL); + log_assert(dbenv != NULL); + log_assert(txn == NULL); ret = dbenv->txn_begin(dbenv, NULL, /* No parent transaction */ @@ -275,8 +282,8 @@ void endtrans(void) { int ret; - assert(dbenv != NULL); - assert(txn != NULL); + log_assert(dbenv != NULL); + log_assert(txn != NULL); ret = txn->commit(txn, 0);