Loading...
Searching...
No Matches
midl.h
Go to the documentation of this file.
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 2000-2021 The OpenLDAP Foundation.
* Portions Copyright 2001-2021 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
#ifndef _MDB_MIDL_H_
#define _MDB_MIDL_H_
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef size_t MDB_ID;
typedef MDB_ID *MDB_IDL;
/* IDL sizes - likely should be even bigger
* limiting factors: sizeof(ID), thread stack size
*/
#ifndef MDB_IDL_LOGN
#define MDB_IDL_LOGN 16 /* DB_SIZE is 2^16, UM_SIZE is 2^17 */
#endif
#define MDB_IDL_DB_SIZE (1<<MDB_IDL_LOGN)
#define MDB_IDL_UM_SIZE (1<<(MDB_IDL_LOGN+1))
#define MDB_IDL_DB_MAX (MDB_IDL_DB_SIZE-1)
#define MDB_IDL_UM_MAX (MDB_IDL_UM_SIZE-1)
#define MDB_IDL_SIZEOF(ids) (((ids)[0]+1) * sizeof(MDB_ID))
#define MDB_IDL_IS_ZERO(ids) ( (ids)[0] == 0 )
#define MDB_IDL_CPY( dst, src ) (memcpy( dst, src, MDB_IDL_SIZEOF( src ) ))
#define MDB_IDL_FIRST( ids ) ( (ids)[1] )
#define MDB_IDL_LAST( ids ) ( (ids)[(ids)[0]] )
#define MDB_IDL_ALLOCLEN( ids ) ( (ids)[-1] )
#define mdb_midl_xappend(idl, id) do { \
MDB_ID *xidl = (idl), xlen = ++(xidl[0]); \
xidl[xlen] = (id); \
} while (0)
unsigned mdb_midl_search( MDB_IDL ids, MDB_ID id );
MDB_IDL mdb_midl_alloc(int num);
void mdb_midl_free(MDB_IDL ids);
void mdb_midl_shrink(MDB_IDL *idp);
int mdb_midl_need(MDB_IDL *idp, unsigned num);
int mdb_midl_append( MDB_IDL *idp, MDB_ID id );
int mdb_midl_append_list( MDB_IDL *idp, MDB_IDL app );
int mdb_midl_append_range( MDB_IDL *idp, MDB_ID id, unsigned n );
void mdb_midl_xmerge( MDB_IDL idl, MDB_IDL merge );
void mdb_midl_sort( MDB_IDL ids );
typedef struct MDB_ID2 {
MDB_ID mid;
void *mptr;
} MDB_ID2;
typedef MDB_ID2 *MDB_ID2L;
unsigned mdb_mid2l_search( MDB_ID2L ids, MDB_ID id );
int mdb_mid2l_insert( MDB_ID2L ids, MDB_ID2 *id );
int mdb_mid2l_append( MDB_ID2L ids, MDB_ID2 *id );
#ifdef __cplusplus
}
#endif
#endif /* _MDB_MIDL_H_ */
MDB_ID2::mid
MDB_ID mid
Definition midl.h:150
MDB_ID2::mptr
void * mptr
Definition midl.h:151
mdb_midl_free
void mdb_midl_free(MDB_IDL ids)
Definition midl.c:114
mdb_midl_append_list
int mdb_midl_append_list(MDB_IDL *idp, MDB_IDL app)
Definition midl.c:171
MDB_IDL
MDB_ID * MDB_IDL
Definition midl.h:54
mdb_midl_need
int mdb_midl_need(MDB_IDL *idp, unsigned num)
Definition midl.c:143
mdb_midl_xmerge
void mdb_midl_xmerge(MDB_IDL idl, MDB_IDL merge)
Definition midl.c:201
mdb_mid2l_search
unsigned mdb_mid2l_search(MDB_ID2L ids, MDB_ID id)
Definition midl.c:281
mdb_mid2l_append
int mdb_mid2l_append(MDB_ID2L ids, MDB_ID2 *id)
Definition midl.c:347
mdb_mid2l_insert
int mdb_mid2l_insert(MDB_ID2L ids, MDB_ID2 *id)
Definition midl.c:316
mdb_midl_shrink
void mdb_midl_shrink(MDB_IDL *idp)
Definition midl.c:120
mdb_midl_search
unsigned mdb_midl_search(MDB_IDL ids, MDB_ID id)
Definition midl.c:34
mdb_midl_alloc
MDB_IDL mdb_midl_alloc(int num)
Definition midl.c:104
mdb_midl_sort
void mdb_midl_sort(MDB_IDL ids)
Definition midl.c:221
mdb_midl_append_range
int mdb_midl_append_range(MDB_IDL *idp, MDB_ID id, unsigned n)
Definition midl.c:185
MDB_ID
size_t MDB_ID
Definition midl.h:46
mdb_midl_append
int mdb_midl_append(MDB_IDL *idp, MDB_ID id)
Definition midl.c:157
MDB_ID2L
MDB_ID2 * MDB_ID2L
Definition midl.h:159
MDB_ID2
Definition midl.h:149