59 #define MDB_IDL_LOGN 16
60 #define MDB_IDL_DB_SIZE (1<<MDB_IDL_LOGN)
61 #define MDB_IDL_UM_SIZE (1<<(MDB_IDL_LOGN+1))
63 #define MDB_IDL_DB_MAX (MDB_IDL_DB_SIZE-1)
64 #define MDB_IDL_UM_MAX (MDB_IDL_UM_SIZE-1)
66 #define MDB_IDL_SIZEOF(ids) (((ids)[0]+1) * sizeof(MDB_ID))
67 #define MDB_IDL_IS_ZERO(ids) ( (ids)[0] == 0 )
68 #define MDB_IDL_CPY( dst, src ) (memcpy( dst, src, MDB_IDL_SIZEOF( src ) ))
69 #define MDB_IDL_FIRST( ids ) ( (ids)[1] )
70 #define MDB_IDL_LAST( ids ) ( (ids)[(ids)[0]] )
73 #define MDB_IDL_ALLOCLEN( ids ) ( (ids)[-1] )
76 #define mdb_midl_xappend(idl, id) do { \
77 MDB_ID *xidl = (idl), xlen = ++(xidl[0]); \
void mdb_midl_free(MDB_IDL ids)
Free an IDL.
int mdb_midl_append_list(MDB_IDL *idp, MDB_IDL app)
Append an IDL onto an IDL.
MDB_ID * MDB_IDL
An IDL is an ID List, a sorted array of IDs.
int mdb_midl_need(MDB_IDL *idp, unsigned num)
Make room for num additional elements in an IDL.
void mdb_midl_xmerge(MDB_IDL idl, MDB_IDL merge)
Merge an IDL onto an IDL.
struct MDB_ID2 MDB_ID2
An ID2 is an ID/pointer pair.
unsigned mdb_mid2l_search(MDB_ID2L ids, MDB_ID id)
Search for an ID in an ID2L.
int mdb_mid2l_append(MDB_ID2L ids, MDB_ID2 *id)
Append an ID2 into a ID2L.
int mdb_mid2l_insert(MDB_ID2L ids, MDB_ID2 *id)
Insert an ID2 into a ID2L.
void mdb_midl_shrink(MDB_IDL *idp)
Shrink an IDL.
unsigned mdb_midl_search(MDB_IDL ids, MDB_ID id)
Search for an ID in an IDL.
MDB_IDL mdb_midl_alloc(int num)
Allocate an IDL.
void mdb_midl_sort(MDB_IDL ids)
Sort an IDL.
int mdb_midl_append_range(MDB_IDL *idp, MDB_ID id, unsigned n)
Append an ID range onto an IDL.
size_t MDB_ID
A generic unsigned ID number.
int mdb_midl_append(MDB_IDL *idp, MDB_ID id)
Append an ID onto an IDL.
MDB_ID2 * MDB_ID2L
An ID2L is an ID2 List, a sorted array of ID2s.
An ID2 is an ID/pointer pair.