From 20baad4a207db5d0e84fc3a7409f216aefa59385 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Thu, 12 Apr 2012 07:34:14 +0200 Subject: [PATCH] libmdb: midl.h namespace cleanup. Prefix ID, NOID, ID2, IDL, ID2L with 'MDB_'. Also drop bdb from file description. --- libraries/libmdb/mdb.c | 28 ++++++++++++------------- libraries/libmdb/midl.c | 44 +++++++++++++++++++-------------------- libraries/libmdb/midl.h | 46 ++++++++++++++++++++--------------------- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index a9ebbc31f0..6633f928f1 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -238,12 +238,12 @@ * @note In the #MDB_node structure, we only store 48 bits of this value, * which thus limits us to only 60 bits of addressable data. */ -typedef ID pgno_t; +typedef MDB_ID pgno_t; /** A transaction ID. * See struct MDB_txn.mt_txnid for details. */ -typedef ID txnid_t; +typedef MDB_ID txnid_t; /** @defgroup debug Debug Macros * @{ @@ -819,9 +819,9 @@ struct MDB_txn { MDB_env *mt_env; /**< the DB environment */ /** The list of pages that became unused during this transaction. */ - IDL mt_free_pgs; + MDB_IDL mt_free_pgs; union { - ID2L dirty_list; /**< modified pages */ + MDB_ID2L dirty_list; /**< modified pages */ MDB_reader *reader; /**< this thread's slot in the reader table */ } mt_u; /** Array of records for each DB known in the environment. */ @@ -961,9 +961,9 @@ struct MDB_env { pthread_key_t me_txkey; /**< thread-key for readers */ MDB_page *me_dpages; /**< list of malloc'd blocks for re-use */ /** IDL of pages that became unused in a write txn */ - IDL me_free_pgs; + MDB_IDL me_free_pgs; /** ID2L of pages that were written during a write txn */ - ID2 me_dirty_list[MDB_IDL_UM_SIZE]; + MDB_ID2 me_dirty_list[MDB_IDL_UM_SIZE]; /** rwlock for the DB tables, if #LAZY_LOCKS is false */ LAZY_RWLOCK_DEF(me_dblock) #ifdef _WIN32 @@ -1129,14 +1129,14 @@ static void mdb_audit(MDB_txn *txn) { MDB_cursor mc; MDB_val key, data; + MDB_ID freecount, count; MDB_dbi i; int rc; - ID freecount, count; freecount = 0; mdb_cursor_init(&mc, txn, FREE_DBI, NULL); while ((rc = mdb_cursor_get(&mc, &key, &data, MDB_NEXT)) == 0) - freecount += *(ID *)data.mv_data; + freecount += *(MDB_ID *)data.mv_data; freecount += txn->mt_dbs[0].md_branch_pages + txn->mt_dbs[0].md_leaf_pages + txn->mt_dbs[0].md_overflow_pages; @@ -1217,7 +1217,7 @@ mdb_page_alloc(MDB_cursor *mc, int num) MDB_txn *txn = mc->mc_txn; MDB_page *np; pgno_t pgno = P_INVALID; - ID2 mid; + MDB_ID2 mid; if (txn->mt_txnid > 2) { @@ -1272,7 +1272,7 @@ again: txn->mt_env->me_pglast = last; if (!txn->mt_env->me_pgfirst) txn->mt_env->me_pgfirst = last; - idl = (ID *) data.mv_data; + idl = (MDB_ID *) data.mv_data; /* We might have a zero-length IDL due to freelist growth * during a prior commit */ @@ -1410,7 +1410,7 @@ finish: mc->mc_db->md_root = mp->mp_pgno; } else if (mc->mc_txn->mt_parent) { MDB_page *np; - ID2 mid; + MDB_ID2 mid; /* If txn has a parent, make sure the page is in our * dirty list. */ @@ -1679,7 +1679,7 @@ mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **ret) free(txn); return ENOMEM; } - txn->mt_u.dirty_list = malloc(sizeof(ID2)*MDB_IDL_UM_SIZE); + txn->mt_u.dirty_list = malloc(sizeof(MDB_ID2)*MDB_IDL_UM_SIZE); if (!txn->mt_u.dirty_list) { free(txn->mt_free_pgs); free(txn); @@ -1866,7 +1866,7 @@ mdb_txn_commit(MDB_txn *txn) MDB_db *ip, *jp; MDB_dbi i; unsigned x, y; - ID2L dst, src; + MDB_ID2L dst, src; /* Update parent's DB table */ ip = &txn->mt_parent->mt_dbs[2]; @@ -1961,7 +1961,7 @@ free2: #if MDB_DEBUG > 1 { unsigned int i; - ID *idl = txn->mt_free_pgs; + MDB_IDL idl = txn->mt_free_pgs; DPRINTF("IDL write txn %zu root %zu num %zu", txn->mt_txnid, txn->mt_dbs[FREE_DBI].md_root, idl[0]); for (i=0; i (y) ) #if 0 /* superseded by append/sort */ -static unsigned mdb_midl_search( IDL ids, ID id ) +static unsigned mdb_midl_search( MDB_IDL ids, MDB_ID id ) { /* * binary search of id in ids @@ -66,7 +66,7 @@ static unsigned mdb_midl_search( IDL ids, ID id ) return cursor; } -int mdb_midl_insert( IDL ids, ID id ) +int mdb_midl_insert( MDB_IDL ids, MDB_ID id ) { unsigned x, i; @@ -104,7 +104,7 @@ int mdb_midl_insert( IDL ids, ID id ) } else { ids[2] = ids[ids[0]-1]; } - ids[0] = NOID; + ids[0] = MDB_NOID; } else { /* insert id */ @@ -117,23 +117,23 @@ int mdb_midl_insert( IDL ids, ID id ) } #endif -IDL mdb_midl_alloc() +MDB_IDL mdb_midl_alloc() { - IDL ids = malloc((MDB_IDL_UM_MAX+1) * sizeof(ID)); + MDB_IDL ids = malloc((MDB_IDL_UM_MAX+1) * sizeof(MDB_ID)); *ids++ = MDB_IDL_UM_MAX; return ids; } -void mdb_midl_free(IDL ids) +void mdb_midl_free(MDB_IDL ids) { free(ids-1); } -int mdb_midl_shrink( IDL *idp ) +int mdb_midl_shrink( MDB_IDL *idp ) { - IDL ids = *idp; + MDB_IDL ids = *idp; if (ids[-1] > MDB_IDL_UM_MAX) { - ids = realloc(ids, (MDB_IDL_UM_MAX+1) * sizeof(ID)); + ids = realloc(ids, (MDB_IDL_UM_MAX+1) * sizeof(MDB_ID)); *ids++ = MDB_IDL_UM_MAX; *idp = ids; return 1; @@ -141,14 +141,14 @@ int mdb_midl_shrink( IDL *idp ) return 0; } -int mdb_midl_append( IDL *idp, ID id ) +int mdb_midl_append( MDB_IDL *idp, MDB_ID id ) { - IDL ids = *idp; + MDB_IDL ids = *idp; /* Too big? */ if (ids[0] >= ids[-1]) { - IDL idn = ids-1; + MDB_IDL idn = ids-1; /* grow it */ - idn = realloc(idn, (*idn + MDB_IDL_UM_MAX + 1) * sizeof(ID)); + idn = realloc(idn, (*idn + MDB_IDL_UM_MAX + 1) * sizeof(MDB_ID)); if (!idn) return -1; *idn++ += MDB_IDL_UM_MAX; @@ -160,21 +160,21 @@ int mdb_midl_append( IDL *idp, ID id ) return 0; } -int mdb_midl_append_list( IDL *idp, IDL app ) +int mdb_midl_append_list( MDB_IDL *idp, MDB_IDL app ) { - IDL ids = *idp; + MDB_IDL ids = *idp; /* Too big? */ if (ids[0] + app[0] >= ids[-1]) { - IDL idn = ids-1; + MDB_IDL idn = ids-1; /* grow it */ - idn = realloc(idn, (*idn + app[-1]) * sizeof(ID)); + idn = realloc(idn, (*idn + app[-1]) * sizeof(MDB_ID)); if (!idn) return -1; *idn++ += app[-1]; ids = idn; *idp = ids; } - memcpy(&ids[ids[0]+1], &app[1], app[0] * sizeof(ID)); + memcpy(&ids[ids[0]+1], &app[1], app[0] * sizeof(MDB_ID)); ids[0] += app[0]; return 0; } @@ -185,12 +185,12 @@ int mdb_midl_append_list( IDL *idp, IDL app ) #define SWAP(a,b) { itmp=(a); (a)=(b); (b)=itmp; } void -mdb_midl_sort( IDL ids ) +mdb_midl_sort( MDB_IDL ids ) { /* Max possible depth of int-indexed tree * 2 items/level */ int istack[sizeof(int)*CHAR_BIT * 2]; int i,j,k,l,ir,jstack; - ID a, itmp; + MDB_ID a, itmp; ir = ids[0]; l = 1; @@ -245,7 +245,7 @@ mdb_midl_sort( IDL ids ) } } -unsigned mdb_mid2l_search( ID2L ids, ID id ) +unsigned mdb_mid2l_search( MDB_ID2L ids, MDB_ID id ) { /* * binary search of id in ids @@ -280,7 +280,7 @@ unsigned mdb_mid2l_search( ID2L ids, ID id ) return cursor; } -int mdb_mid2l_insert( ID2L ids, ID2 *id ) +int mdb_mid2l_insert( MDB_ID2L ids, MDB_ID2 *id ) { unsigned x, i; diff --git a/libraries/libmdb/midl.h b/libraries/libmdb/midl.h index 59ed8cb660..f072ca34a9 100644 --- a/libraries/libmdb/midl.h +++ b/libraries/libmdb/midl.h @@ -1,5 +1,5 @@ /** @file midl.h - * @brief ldap bdb back-end ID List header file. + * @brief mdb ID List header file. * * This file was originally part of back-bdb but has been * modified for use in libmdb. Most of the macros defined @@ -42,7 +42,7 @@ extern "C" { /** A generic ID number. These were entryIDs in back-bdb. * Preferably it should have the same size as a pointer. */ -typedef size_t ID; +typedef size_t MDB_ID; /** An IDL is an ID List, a sorted array of IDs. The first * element of the array is a counter for how many actual @@ -50,9 +50,9 @@ typedef size_t ID; * sorted in ascending order. For libmdb IDLs are sorted in * descending order. */ -typedef ID *IDL; +typedef MDB_ID *MDB_IDL; -#define NOID (~(ID)0) +#define MDB_NOID (~(MDB_ID)0) /* IDL sizes - likely should be even bigger * limiting factors: sizeof(ID), thread stack size @@ -60,24 +60,24 @@ typedef ID *IDL; #define MDB_IDL_LOGN 16 /* DB_SIZE is 2^16, UM_SIZE is 2^17 */ #define MDB_IDL_DB_SIZE (1<