- 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;
- }
- dbenv->close(dbenv, 0);
- dbenv = NULL;
-}
-
-/**
- * starttrans - Start a transaction.
- *
- * Start a transaction. Intended to be used if we're about to perform many
- * operations on the database to help speed it all up, or if we want
- * something to only succeed if all relevant operations are successful.
- */
-bool starttrans(void)
-{
- int ret;
-
- assert(dbenv != NULL);
- assert(txn == NULL);
-
- ret = dbenv->txn_begin(dbenv,
- NULL, /* No parent transaction */
- &txn,
- 0);
- if (ret != 0) {
- logthing(LOGTHING_CRITICAL,
- "Error starting transaction: %s",
- db_strerror(ret));
- exit(1);
- }
-
- return true;
-}
-
-/**
- * endtrans - End a transaction.
- *
- * Ends a transaction.
- */
-void endtrans(void)
-{
- int ret;
-
- assert(dbenv != NULL);
- assert(txn != NULL);
-
- ret = txn->commit(txn,
- 0);
- if (ret != 0) {
- logthing(LOGTHING_CRITICAL,
- "Error ending transaction: %s",
- db_strerror(ret));
- exit(1);
+ 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;
+ }
+ }
+ free(dbconns);
+ dbconns = NULL;
+ dbenv->close(dbenv, 0);
+ dbenv = NULL;