]> git.sommitrealweird.co.uk Git - onak.git/blobdiff - keydb_db4.c
Change to using Autoconf version string.
[onak.git] / keydb_db4.c
index 04949d000ce90dd48a37401f12cf15855434530f..0d7b46b935de0dd422b7e4cea340aada5b726be1 100644 (file)
@@ -6,7 +6,6 @@
  * Copyright 2002-2004 Project Purple
  */
 
-#include <assert.h>
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <ctype.h>
@@ -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);