X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Fliblmdb%2Fmtest2.c;h=b68aade819f3766744efd66a803ead6278b42bfa;hb=ea7d99d97089457446d204d0589776107017a06c;hp=ebda8521e4eb3eb56ca255a5bc068e74e17fdb8f;hpb=e2bdd44624a525d4847c22d7ebf1ea4d154ed734;p=openldap diff --git a/libraries/liblmdb/mtest2.c b/libraries/liblmdb/mtest2.c index ebda8521e4..b68aade819 100644 --- a/libraries/liblmdb/mtest2.c +++ b/libraries/liblmdb/mtest2.c @@ -1,6 +1,6 @@ /* mtest2.c - memory-mapped database tester/toy */ /* - * Copyright 2011 Howard Chu, Symas Corp. + * Copyright 2011-2016 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,6 @@ /* Just like mtest.c, but using a subDB instead of the main DB */ -#define _XOPEN_SOURCE 500 /* srandom(), random() */ #include #include #include @@ -38,30 +37,32 @@ int main(int argc,char * argv[]) int *values; char sval[32] = ""; - srandom(time(NULL)); + srand(time(NULL)); - count = (random()%384) + 64; + count = (rand()%384) + 64; values = (int *)malloc(count*sizeof(int)); for(i = 0;i -1; i-= (random()%5)) { + for (i= count - 1; i > -1; i-= (rand()%5)) { j++; txn=NULL; E(mdb_txn_begin(env, NULL, 0, &txn)); @@ -98,7 +99,7 @@ int main(int argc,char * argv[]) printf("Deleted %d values\n", j); E(mdb_env_stat(env, &mst)); - E(mdb_txn_begin(env, NULL, 1, &txn)); + E(mdb_txn_begin(env, NULL, MDB_RDONLY, &txn)); E(mdb_cursor_open(txn, dbi, &cursor)); printf("Cursor next\n"); while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { @@ -115,10 +116,9 @@ int main(int argc,char * argv[]) } CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get"); mdb_cursor_close(cursor); - mdb_close(env, dbi); - mdb_txn_abort(txn); - mdb_env_close(env); + mdb_dbi_close(env, dbi); + mdb_env_close(env); return 0; }