From bccbcd1938269de42e81af163a3cbfb7216f0d56 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 25 Mar 2013 11:53:32 -0700 Subject: [PATCH 1/2] Silence stupid warnings --- libraries/liblmdb/midl.c | 8 ++++---- libraries/liblmdb/midl.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/liblmdb/midl.c b/libraries/liblmdb/midl.c index 3bfb61f174..8020edc0ae 100644 --- a/libraries/liblmdb/midl.c +++ b/libraries/liblmdb/midl.c @@ -117,7 +117,7 @@ int mdb_midl_insert( MDB_IDL ids, MDB_ID id ) } #endif -MDB_IDL mdb_midl_alloc() +MDB_IDL mdb_midl_alloc(void) { MDB_IDL ids = malloc((MDB_IDL_UM_MAX+1) * sizeof(MDB_ID)); *ids++ = MDB_IDL_UM_MAX; @@ -192,7 +192,7 @@ mdb_midl_sort( MDB_IDL ids ) int i,j,k,l,ir,jstack; MDB_ID a, itmp; - ir = ids[0]; + ir = (int)ids[0]; l = 1; jstack = 0; for(;;) { @@ -255,7 +255,7 @@ unsigned mdb_mid2l_search( MDB_ID2L ids, MDB_ID id ) unsigned base = 0; unsigned cursor = 1; int val = 0; - unsigned n = ids[0].mid; + unsigned n = (unsigned)ids[0].mid; while( 0 < n ) { unsigned pivot = n >> 1; @@ -304,7 +304,7 @@ int mdb_mid2l_insert( MDB_ID2L ids, MDB_ID2 *id ) } else { /* insert id */ ids[0].mid++; - for (i=ids[0].mid; i>x; i--) + for (i=(unsigned)ids[0].mid; i>x; i--) ids[i] = ids[i-1]; ids[x] = *id; } diff --git a/libraries/liblmdb/midl.h b/libraries/liblmdb/midl.h index b4066a84d9..a284223ab3 100644 --- a/libraries/liblmdb/midl.h +++ b/libraries/liblmdb/midl.h @@ -118,7 +118,7 @@ int mdb_midl_insert( MDB_IDL ids, MDB_ID id ); * Allocates memory for an IDL of a default size. * @return IDL on success, NULL on failure. */ -MDB_IDL mdb_midl_alloc(); +MDB_IDL mdb_midl_alloc(void); /** Free an IDL. * @param[in] ids The IDL to free. From 8a99b00acc6fc737b825c979c057a98a081e4e68 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 25 Mar 2013 12:15:53 -0700 Subject: [PATCH 2/2] ITS#7553 deinit cursor after deleting last node --- libraries/liblmdb/mdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 3329565893..ec003b759d 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -6403,7 +6403,7 @@ mdb_rebalance(MDB_cursor *mc) static int mdb_cursor_del0(MDB_cursor *mc, MDB_node *leaf) { - int rc; + int rc, eof; /* add overflow pages to free list */ if (!IS_LEAF2(mc->mc_pg[mc->mc_top]) && F_ISSET(leaf->mn_flags, F_BIGDATA)) { @@ -6421,9 +6421,12 @@ mdb_cursor_del0(MDB_cursor *mc, MDB_node *leaf) } mdb_node_del(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top], mc->mc_db->md_pad); mc->mc_db->md_entries--; + eof = mc->mc_flags & C_EOF; rc = mdb_rebalance(mc); if (rc != MDB_SUCCESS) mc->mc_txn->mt_flags |= MDB_TXN_ERROR; + else if (eof) + mc->mc_flags &= ~C_INITIALIZED; return rc; }