Merge remote-tracking branch 'origin/mdb.master'

This commit is contained in:
Howard Chu 2012-08-24 05:34:29 -07:00
commit f980c64cb6
2 changed files with 12 additions and 8 deletions

View File

@ -36,17 +36,17 @@ int main(int argc,char * argv[])
rc = mdb_env_open(env, envname, MDB_RDONLY, 0);
if (rc) {
printf("mdb_env_open failed, error %d\n", rc);
exit(1);
goto env_close;
}
rc = mdb_txn_begin(env, NULL, 1, &txn);
if (rc) {
printf("mdb_txn_begin failed, error %d\n", rc);
exit(1);
goto env_close;
}
rc = mdb_open(txn, subname, 0, &dbi);
if (rc) {
printf("mdb_open failed, error %d\n", rc);
exit(1);
goto txn_abort;
}
rc = mdb_stat(txn, dbi, &mst);
@ -57,8 +57,10 @@ int main(int argc,char * argv[])
printf("Overflow pages: %zu\n", mst.ms_overflow_pages);
printf("Entries: %zu\n", mst.ms_entries);
mdb_close(env, dbi);
txn_abort:
mdb_txn_abort(txn);
env_close:
mdb_env_close(env);
return 0;
return rc ? EXIT_FAILURE : EXIT_SUCCESS;
}

View File

@ -34,17 +34,17 @@ int main(int argc,char * argv[])
rc = mdb_env_open(env, envname, MDB_RDONLY, 0);
if (rc) {
printf("mdb_env_open failed, error %d\n", rc);
exit(1);
goto env_close;
}
rc = mdb_txn_begin(env, NULL, 1, &txn);
if (rc) {
printf("mdb_txn_begin failed, error %d\n", rc);
exit(1);
goto env_close;
}
rc = mdb_open(txn, NULL, 0, &dbi);
if (rc) {
printf("mdb_open failed, error %d\n", rc);
exit(1);
goto txn_abort;
}
rc = mdb_stat(txn, dbi, &mst);
@ -75,8 +75,10 @@ int main(int argc,char * argv[])
}
mdb_cursor_close(cursor);
mdb_close(env, dbi);
txn_abort:
mdb_txn_abort(txn);
env_close:
mdb_env_close(env);
return 0;
return rc ? EXIT_FAILURE : EXIT_SUCCESS;
}