From 36be1040970d1225689caf129a9ca67970334830 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Wed, 20 May 2015 03:17:47 +0200 Subject: [PATCH] lmdb-test: mtest*.c: Fix MDB_NOOVERWRITE, plug cursor leak. Change-Id: Idc2840fafc0d8cb4aaaa2e23b899a9ce7fb2b52b --- mtest0.c | 6 ++++-- mtest2.c | 4 ++-- mtest6.c | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/mtest0.c b/mtest0.c index f27132d1..4fe9a15a 100644 --- a/mtest0.c +++ b/mtest0.c @@ -54,12 +54,13 @@ int main(int argc,char * argv[]) key.mv_size = sizeof(int); key.mv_data = sval; - data.mv_size = sizeof(sval); - data.mv_data = sval; printf("Adding %d values\n", count); for (i=0;i in each iteration, since MDB_NOOVERWRITE may modify it */ + data.mv_size = sizeof(sval); + data.mv_data = sval; if (RES(MDB_KEYEXIST, mdb_put(txn, dbi, &key, &data, MDB_NOOVERWRITE))) { j++; data.mv_size = sizeof(sval); @@ -130,6 +131,7 @@ int main(int argc,char * argv[]) (int) key.mv_size, (char *) key.mv_data, (int) data.mv_size, (char *) data.mv_data); + mdb_cursor_close(cursor); mdb_txn_abort(txn); printf("Deleting with cursor\n"); diff --git a/mtest2.c b/mtest2.c index d04e08ae..e1ab1ca8 100644 --- a/mtest2.c +++ b/mtest2.c @@ -59,12 +59,12 @@ int main(int argc,char * argv[]) key.mv_size = sizeof(int); key.mv_data = sval; - data.mv_size = sizeof(sval); - data.mv_data = sval; printf("Adding %d values\n", count); for (i=0;i