mdbx: add mdbx_mid2l_sort().

Change-Id: Ib70a46063611b0657b34524d268b2ee5bd9b1eb8
This commit is contained in:
Leonid Yuriev 2018-08-25 17:21:49 +03:00 committed by Leo Yuriev
parent 30b084724a
commit 93a71c29e7

View File

@ -902,6 +902,17 @@ static unsigned __hot mdbx_mid2l_search(MDBX_ID2L pnl, pgno_t id) {
return cursor;
}
static int mdbx_mid2l_cmp(const void *pa, const void *pb) {
const MDBX_ID2 a = *(MDBX_ID2L)pa;
const MDBX_ID2 b = *(MDBX_ID2L)pb;
return mdbx_cmp2int(a.mid, b.mid);
}
static void mdbx_mid2l_sort(MDBX_ID2L ptr) {
/* LY: temporary */
qsort(ptr + 1, (size_t)ptr->mid, sizeof(*ptr), mdbx_mid2l_cmp);
}
/* Insert an ID2 into a ID2L.
* [in,out] pnl The ID2L to insert into.
* [in] id The ID2 to insert.
@ -3659,6 +3670,7 @@ retry:
}
MDBX_ID2L dl = txn->mt_rw_dirtylist;
mdbx_mid2l_sort(dl);
for (MDBX_page *mp = txn->mt_loose_pages; mp;) {
mdbx_tassert(txn, mp->mp_pgno < txn->mt_next_pgno);
mdbx_ensure(env, mp->mp_pgno >= NUM_METAS);