]> git.sur5r.net Git - openldap/commitdiff
Import IDL changes from devel.
authorKurt Zeilenga <kurt@openldap.org>
Sun, 31 Jan 1999 19:13:34 +0000 (19:13 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sun, 31 Jan 1999 19:13:34 +0000 (19:13 +0000)
CHANGES
servers/slapd/back-ldbm/back-ldbm.h
servers/slapd/back-ldbm/dbcache.c
servers/slapd/back-ldbm/filterindex.c
servers/slapd/back-ldbm/id2children.c
servers/slapd/back-ldbm/idl.c
servers/slapd/back-ldbm/index.c
servers/slapd/back-ldbm/proto-back-ldbm.h
servers/slapd/back-ldbm/search.c
servers/slapd/tools/ldbmtest.c

diff --git a/CHANGES b/CHANGES
index dc99db532604369c5d6860e0c571171195e56257..882f8cd1c8c07714d58b81be00ef761e477f64ba 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,8 @@ Changes included in OpenLDAP 1.2
        Fixed slapd/ldbm/add,modrdn,delete e_ndn handling
        Fixed -lldap/ldap_init() bug
        Fixed -lldap/ldap_sort_entries() zero entries bug
+       Fixed slapd/slap_op memory/lock leak bug
+       Updated slapd/back-ldbm IDList handling
        Updated ldap_open(3) man page to note ldap_init() is preferred.
        Updated internal thread library
        Updated slapd/back-shell to use void* private and pid_t
index 032b3cb77778013201e1355cf38d2b859ce8c7e9..e0816acd48ef2b6422a0028a5092522385476af2 100644 (file)
@@ -47,16 +47,26 @@ LDAP_BEGIN_DECL
  *             the list is terminated by an id of NOID.
  *     b_ids   a list of the actual ids themselves
  */
-typedef struct block {
-       ID              b_nmax;         /* max number of ids in this list  */
-#define ALLIDSBLOCK    0               /* == 0 => this is an allid block  */
-       ID              b_nids;         /* current number of ids used      */
-#define INDBLOCK       0               /* == 0 => this is an indirect blk */
-       ID              b_ids[1];       /* the ids - actually bigger       */
-} Block, IDList;
-
-#define ALLIDS( idl )          ((idl)->b_nmax == ALLIDSBLOCK)
-#define INDIRECT_BLOCK( idl )  ((idl)->b_nids == INDBLOCK)
+
+typedef ID ID_BLOCK;
+
+#define ID_BLOCK_NMAX_OFFSET   0
+#define ID_BLOCK_NIDS_OFFSET   1
+#define ID_BLOCK_IDS_OFFSET            2
+
+/* all ID_BLOCK macros operate on a pointer to a ID_BLOCK */
+
+#define ID_BLOCK_NMAX(b)               ((b)[ID_BLOCK_NMAX_OFFSET])
+#define ID_BLOCK_NIDS(b)               ((b)[ID_BLOCK_NIDS_OFFSET])
+#define ID_BLOCK_ID(b, n)              ((b)[ID_BLOCK_IDS_OFFSET+(n)])
+
+#define ID_BLOCK_NOID(b, n)            (ID_BLOCK_ID((b),(n)) == NOID)
+
+#define ID_BLOCK_ALLIDS_VALUE  0
+#define ID_BLOCK_ALLIDS(b)             (ID_BLOCK_NMAX(b) == ID_BLOCK_ALLIDS_VALUE)
+
+#define ID_BLOCK_INDIRECT_VALUE        0
+#define ID_BLOCK_INDIRECT(b)   (ID_BLOCK_NIDS(b) == ID_BLOCK_INDIRECT_VALUE)
 
 /* for the in-core cache of entries */
 struct cache {
index 066a71d8ca36a8e1c3c6a847bb69da8fdd08f363..5e3549ff34f0ca0e8b722f1caa582d5bb6978cde 100644 (file)
@@ -109,7 +109,7 @@ ldbm_cache_open(
                li->li_dbcache[i].dbc_blksize = DEFAULT_BLOCKSIZE;
        }
        li->li_dbcache[i].dbc_maxids = (li->li_dbcache[i].dbc_blksize /
-           sizeof(ID)) - 2;
+           sizeof(ID)) - ID_BLOCK_IDS_OFFSET;
        li->li_dbcache[i].dbc_maxindirect = (SLAPD_LDBM_MIN_MAXIDS /
            li->li_dbcache[i].dbc_maxids) + 1;
 
index 21a9d6ef7c44e0bd60aad7ae7ced7ea2db761f94..5ad17dc0e157bb8d0e9900fe6b308ced87c2f95f 100644 (file)
 #include "slap.h"
 #include "back-ldbm.h"
 
-static IDList  *ava_candidates( Backend *be, Ava *ava, int type );
-static IDList  *presence_candidates( Backend *be, char *type );
-static IDList  *approx_candidates( Backend *be, Ava *ava );
-static IDList  *list_candidates( Backend *be, Filter *flist, int ftype );
-static IDList  *substring_candidates( Backend *be, Filter *f );
-static IDList  *substring_comp_candidates( Backend *be, char *type, char *val, int prepost );
+static ID_BLOCK        *ava_candidates( Backend *be, Ava *ava, int type );
+static ID_BLOCK        *presence_candidates( Backend *be, char *type );
+static ID_BLOCK        *approx_candidates( Backend *be, Ava *ava );
+static ID_BLOCK        *list_candidates( Backend *be, Filter *flist, int ftype );
+static ID_BLOCK        *substring_candidates( Backend *be, Filter *f );
+static ID_BLOCK        *substring_comp_candidates( Backend *be, char *type, char *val, int prepost );
 
 /*
  * test_filter - test a filter against a single entry.
@@ -24,13 +24,13 @@ static IDList       *substring_comp_candidates( Backend *be, char *type, char *val, in
  *             >0      an ldap error code
  */
 
-IDList *
+ID_BLOCK *
 filter_candidates(
     Backend    *be,
     Filter     *f
 )
 {
-       IDList  *result, *tmp1, *tmp2;
+       ID_BLOCK        *result, *tmp1, *tmp2;
 
        Debug( LDAP_DEBUG_TRACE, "=> filter_candidates\n", 0, 0, 0 );
 
@@ -87,18 +87,18 @@ filter_candidates(
        }
 
        Debug( LDAP_DEBUG_TRACE, "<= filter_candidates %lu\n",
-           result ? result->b_nids : 0, 0, 0 );
+           result ? ID_BLOCK_NIDS(result) : 0, 0, 0 );
        return( result );
 }
 
-static IDList *
+static ID_BLOCK *
 ava_candidates(
     Backend    *be,
     Ava                *ava,
     int                type
 )
 {
-       IDList  *idl;
+       ID_BLOCK        *idl;
 
        Debug( LDAP_DEBUG_TRACE, "=> ava_candidates 0x%x\n", type, 0, 0 );
 
@@ -118,35 +118,35 @@ ava_candidates(
        }
 
        Debug( LDAP_DEBUG_TRACE, "<= ava_candidates %lu\n",
-           idl ? idl->b_nids : 0, 0, 0 );
+           idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
        return( idl );
 }
 
-static IDList *
+static ID_BLOCK *
 presence_candidates(
     Backend    *be,
     char       *type
 )
 {
-       IDList  *idl;
+       ID_BLOCK        *idl;
 
        Debug( LDAP_DEBUG_TRACE, "=> presence_candidates\n", 0, 0, 0 );
 
        idl = index_read( be, type, 0, "*" );
 
        Debug( LDAP_DEBUG_TRACE, "<= presence_candidates %lu\n",
-           idl ? idl->b_nids : 0, 0, 0 );
+           idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
        return( idl );
 }
 
-static IDList *
+static ID_BLOCK *
 approx_candidates(
     Backend    *be,
     Ava                *ava
 )
 {
        char    *w, *c;
-       IDList  *idl, *tmp;
+       ID_BLOCK        *idl, *tmp;
 
        Debug( LDAP_DEBUG_TRACE, "=> approx_candidates\n", 0, 0, 0 );
 
@@ -172,18 +172,18 @@ approx_candidates(
        }
 
        Debug( LDAP_DEBUG_TRACE, "<= approx_candidates %lu\n",
-           idl ? idl->b_nids : 0, 0, 0 );
+           idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
        return( idl );
 }
 
-static IDList *
+static ID_BLOCK *
 list_candidates(
     Backend    *be,
     Filter     *flist,
     int                ftype
 )
 {
-       IDList  *idl, *tmp, *tmp2;
+       ID_BLOCK        *idl, *tmp, *tmp2;
        Filter  *f;
 
        Debug( LDAP_DEBUG_TRACE, "=> list_candidates 0x%x\n", ftype, 0, 0 );
@@ -213,18 +213,18 @@ list_candidates(
        }
 
        Debug( LDAP_DEBUG_TRACE, "<= list_candidates %lu\n",
-           idl ? idl->b_nids : 0, 0, 0 );
+           idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
        return( idl );
 }
 
-static IDList *
+static ID_BLOCK *
 substring_candidates(
     Backend    *be,
     Filter     *f
 )
 {
        int     i;
-       IDList  *idl, *tmp, *tmp2;
+       ID_BLOCK        *idl, *tmp, *tmp2;
 
        Debug( LDAP_DEBUG_TRACE, "=> substring_candidates\n", 0, 0, 0 );
 
@@ -280,11 +280,11 @@ substring_candidates(
        }
 
        Debug( LDAP_DEBUG_TRACE, "<= substring_candidates %lu\n",
-           idl ? idl->b_nids : 0, 0, 0 );
+           idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
        return( idl );
 }
 
-static IDList *
+static ID_BLOCK *
 substring_comp_candidates(
     Backend    *be,
     char       *type,
@@ -293,7 +293,7 @@ substring_comp_candidates(
 )
 {
        int     i, len;
-       IDList  *idl, *tmp, *tmp2;
+       ID_BLOCK        *idl, *tmp, *tmp2;
        char    *p;
        char    buf[SUBLEN + 1];
 
@@ -348,6 +348,6 @@ substring_comp_candidates(
        }
 
        Debug( LDAP_DEBUG_TRACE, "<= substring_comp_candidates %lu\n",
-           idl ? idl->b_nids : 0, 0, 0 );
+           idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
        return( idl );
 }
index d8e1db98865458584c138f1feb5b2a0f94e739d9..11af4cde18dd6d609f114a641788e2f20d11f30b 100644 (file)
@@ -20,7 +20,7 @@ id2children_add(
        struct dbcache  *db;
        Datum           key;
        int             len, rc;
-       IDList          *idl;
+       ID_BLOCK                *idl;
        char            buf[20];
 
        ldbm_datum_init( key );
@@ -64,7 +64,7 @@ id2children_remove(
        struct dbcache  *db;
        Datum           key;
        int             len, rc;
-       IDList          *idl;
+       ID_BLOCK                *idl;
        char            buf[20];
 
        Debug( LDAP_DEBUG_TRACE, "=> id2children_remove( %lu, %lu )\n", p ? p->e_id
@@ -105,7 +105,7 @@ has_children(
        struct dbcache  *db;
        Datum           key;
        int             rc;
-       IDList          *idl;
+       ID_BLOCK                *idl;
        char            buf[20];
 
        ldbm_datum_init( key );
index 7a4f7d075e0c71dc90aa288e8f922660247b8a3a..7df466cb253a77c5c551d488a8fe74b703378fc0 100644 (file)
 #include "slap.h"
 #include "back-ldbm.h"
 
-IDList *
+ID_BLOCK *
 idl_alloc( int nids )
 {
-       IDList  *new;
+       ID_BLOCK        *new;
 
        /* nmax + nids + space for the ids */
-       new = (IDList *) ch_calloc( (2 + nids), sizeof(ID) );
-       new->b_nmax = nids;
-       new->b_nids = 0;
+       new = (ID_BLOCK *) ch_calloc( (ID_BLOCK_IDS_OFFSET + nids), sizeof(ID) );
+       ID_BLOCK_NMAX(new) = nids;
+       ID_BLOCK_NIDS(new) = 0;
 
        return( new );
 }
 
-IDList *
+ID_BLOCK       *
 idl_allids( Backend *be )
 {
-       IDList  *idl;
+       ID_BLOCK        *idl;
 
        idl = idl_alloc( 0 );
-       idl->b_nmax = ALLIDSBLOCK;
-       idl->b_nids = next_id_get( be );
+       ID_BLOCK_NMAX(idl) = ID_BLOCK_ALLIDS_VALUE;
+       ID_BLOCK_NIDS(idl) = next_id_get( be );
 
        return( idl );
 }
 
 void
-idl_free( IDList *idl )
+idl_free( ID_BLOCK *idl )
 {
        if ( idl == NULL ) {
                return;
@@ -46,7 +46,7 @@ idl_free( IDList *idl )
        free( (char *) idl );
 }
 
-static IDList *
+static ID_BLOCK *
 idl_fetch_one(
     Backend            *be,
     struct dbcache     *db,
@@ -54,7 +54,7 @@ idl_fetch_one(
 )
 {
        Datum   data;
-       IDList  *idl;
+       ID_BLOCK        *idl;
 
        ldbm_datum_init( data );
 
@@ -62,12 +62,12 @@ idl_fetch_one(
 
        data = ldbm_cache_fetch( db, key );
 
-       idl = (IDList *) data.dptr;
+       idl = (ID_BLOCK *) data.dptr;
 
        return( idl );
 }
 
-IDList *
+ID_BLOCK *
 idl_fetch(
     Backend            *be,
     struct dbcache     *db,
@@ -75,8 +75,8 @@ idl_fetch(
 )
 {
        Datum   data, k2;
-       IDList  *idl;
-       IDList  **tmp;
+       ID_BLOCK        *idl;
+       ID_BLOCK        **tmp;
        char    *kstr;
        int     i, nids;
 
@@ -87,19 +87,19 @@ idl_fetch(
 
        data = ldbm_cache_fetch( db, key );
 
-       if ( (idl = (IDList *) data.dptr) == NULL ) {
+       if ( (idl = (ID_BLOCK *) data.dptr) == NULL ) {
                return( NULL );
        }
 
        /* regular block */
-       if ( ! INDIRECT_BLOCK( idl ) ) {
+       if ( ! ID_BLOCK_INDIRECT( idl ) ) {
                /*
                Debug( LDAP_DEBUG_TRACE, "<= idl_fetch %d ids (%d max)\n",
-                   idl->b_nids, idl->b_nmax, 0 );
+                   ID_BLOCK_NIDS(idl), ID_BLOCK_NMAX(idl), 0 );
                */
 
                /* make sure we have the current value of highest id */
-               if ( idl->b_nmax == ALLIDSBLOCK ) {
+               if ( ID_BLOCK_ALLIDS(idl) ) {
                        idl_free( idl );
                        idl = idl_allids( be );
                }
@@ -113,15 +113,15 @@ idl_fetch(
         */
 
        /* count the number of blocks & allocate space for pointers to them */
-       for ( i = 0; idl->b_ids[i] != NOID; i++ )
+       for ( i = 0; !ID_BLOCK_NOID(idl, i); i++ )
                ;       /* NULL */
-       tmp = (IDList **) ch_malloc( (i + 1) * sizeof(IDList *) );
+       tmp = (ID_BLOCK **) ch_malloc( (i + 1) * sizeof(ID_BLOCK *) );
 
        /* read in all the blocks */
        kstr = (char *) ch_malloc( key.dsize + 20 );
        nids = 0;
-       for ( i = 0; idl->b_ids[i] != NOID; i++ ) {
-               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, idl->b_ids[i] );
+       for ( i = 0; !ID_BLOCK_NOID(idl, i); i++ ) {
+               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, ID_BLOCK_ID(idl, i) );
                k2.dptr = kstr;
                k2.dsize = strlen( kstr ) + 1;
 
@@ -131,14 +131,14 @@ idl_fetch(
                        continue;
                }
 
-               nids += tmp[i]->b_nids;
+               nids += ID_BLOCK_NIDS(tmp[i]);
        }
        tmp[i] = NULL;
        idl_free( idl );
 
        /* allocate space for the big block */
        idl = idl_alloc( nids );
-       idl->b_nids = nids;
+       ID_BLOCK_NIDS(idl) = nids;
        nids = 0;
 
        /* copy in all the ids from the component blocks */
@@ -147,16 +147,18 @@ idl_fetch(
                        continue;
                }
 
-               SAFEMEMCPY( (char *) &idl->b_ids[nids], (char *) tmp[i]->b_ids,
-                   tmp[i]->b_nids * sizeof(ID) );
-               nids += tmp[i]->b_nids;
+               SAFEMEMCPY(
+                       (char *) &ID_BLOCK_ID(idl, nids),
+                       (char *) &ID_BLOCK_ID(tmp[i], 0),
+                       ID_BLOCK_NIDS(tmp[i]) * sizeof(ID) );
+               nids += ID_BLOCK_NIDS(tmp[i]);
 
                idl_free( tmp[i] );
        }
        free( (char *) tmp );
 
        Debug( LDAP_DEBUG_TRACE, "<= idl_fetch %lu ids (%lu max)\n",
-              idl->b_nids, idl->b_nmax, 0 );
+              ID_BLOCK_NIDS(idl), ID_BLOCK_NMAX(idl), 0 );
        return( idl );
 }
 
@@ -165,7 +167,7 @@ idl_store(
     Backend            *be,
     struct dbcache     *db,
     Datum              key, 
-    IDList             *idl
+    ID_BLOCK           *idl
 )
 {
        int     rc, flags;
@@ -177,7 +179,7 @@ idl_store(
        /* Debug( LDAP_DEBUG_TRACE, "=> idl_store\n", 0, 0, 0 ); */
 
        data.dptr = (char *) idl;
-       data.dsize = (2 + idl->b_nmax) * sizeof(ID);
+       data.dsize = (ID_BLOCK_IDS_OFFSET + ID_BLOCK_NMAX(idl)) * sizeof(ID);
        
 #ifdef LDBM_DEBUG
        Statslog( LDAP_DEBUG_STATS, "<= idl_store(): rc=%d\n",
@@ -194,40 +196,44 @@ idl_store(
 
 static void
 idl_split_block(
-    IDList     *b,
+    ID_BLOCK   *b,
     ID         id,
-    IDList     **n1,
-    IDList     **n2
+    ID_BLOCK   **n1,
+    ID_BLOCK   **n2
 )
 {
        unsigned int    i;
 
        /* find where to split the block */
-       for ( i = 0; i < b->b_nids && id > b->b_ids[i]; i++ )
+       for ( i = 0; i < ID_BLOCK_NIDS(b) && id > ID_BLOCK_ID(b, i); i++ )
                ;       /* NULL */
 
        *n1 = idl_alloc( i == 0 ? 1 : i );
-       *n2 = idl_alloc( b->b_nids - i + (i == 0 ? 0 : 1));
+       *n2 = idl_alloc( ID_BLOCK_NIDS(b) - i + (i == 0 ? 0 : 1));
 
        /*
         * everything before the id being inserted in the first block
         * unless there is nothing, in which case the id being inserted
         * goes there.
         */
-       SAFEMEMCPY( (char *) &(*n1)->b_ids[0], (char *) &b->b_ids[0],
+       SAFEMEMCPY(
+               (char *) &ID_BLOCK_ID(*n1, 0),
+               (char *) &ID_BLOCK_ID(b, 0),
            i * sizeof(ID) );
-       (*n1)->b_nids = (i == 0 ? 1 : i);
+       ID_BLOCK_NIDS(*n1) = (i == 0 ? 1 : i);
 
        if ( i == 0 ) {
-               (*n1)->b_ids[0] = id;
+               ID_BLOCK_ID(*n1, 0) = id;
        } else {
-               (*n2)->b_ids[0] = id;
+               ID_BLOCK_ID(*n2, 0) = id;
        }
 
        /* the id being inserted & everything after in the second block */
-       SAFEMEMCPY( (char *) &(*n2)->b_ids[i == 0 ? 0 : 1],
-           (char *) &b->b_ids[i], (b->b_nids - i) * sizeof(ID) );
-       (*n2)->b_nids = b->b_nids - i + (i == 0 ? 0 : 1);
+       SAFEMEMCPY(
+               (char *) &ID_BLOCK_ID(*n2, (i == 0 ? 0 : 1)),
+           (char *) &ID_BLOCK_ID(b, i),
+               (ID_BLOCK_NIDS(b) - i) * sizeof(ID) );
+       ID_BLOCK_NIDS(*n2) = ID_BLOCK_NIDS(b) - i + (i == 0 ? 0 : 1);
 }
 
 /*
@@ -241,10 +247,10 @@ idl_change_first(
     Backend            *be,
     struct dbcache     *db,
     Datum              hkey,           /* header block key     */
-    IDList             *h,             /* header block         */
+    ID_BLOCK           *h,             /* header block         */
     int                        pos,            /* pos in h to update   */
     Datum              bkey,           /* data block key       */
-    IDList             *b              /* data block           */
+    ID_BLOCK           *b              /* data block           */
 )
 {
        int     rc;
@@ -260,7 +266,7 @@ idl_change_first(
        }
 
        /* write block with new key */
-       sprintf( bkey.dptr, "%c%s%ld", CONT_PREFIX, hkey.dptr, b->b_ids[0] );
+       sprintf( bkey.dptr, "%c%s%ld", CONT_PREFIX, hkey.dptr, ID_BLOCK_ID(b, 0) );
        bkey.dsize = strlen( bkey.dptr ) + 1;
        if ( (rc = idl_store( be, db, bkey, b )) != 0 ) {
                Debug( LDAP_DEBUG_ANY,
@@ -269,7 +275,7 @@ idl_change_first(
        }
 
        /* update + write indirect header block */
-       h->b_ids[pos] = b->b_ids[0];
+       ID_BLOCK_ID(h, pos) = ID_BLOCK_ID(b, 0);
        if ( (rc = idl_store( be, db, hkey, h )) != 0 ) {
                Debug( LDAP_DEBUG_ANY,
                    "idl_store of (%s) returns %d\n", hkey.dptr, rc, 0 );
@@ -288,7 +294,7 @@ idl_insert_key(
 )
 {
        int     i, j, first, rc;
-       IDList  *idl, *tmp, *tmp2, *tmp3;
+       ID_BLOCK        *idl, *tmp, *tmp2, *tmp3;
        char    *kstr;
        Datum   k2;
 
@@ -301,7 +307,7 @@ idl_insert_key(
 #endif
 
                idl = idl_alloc( 1 );
-               idl->b_ids[idl->b_nids++] = id;
+               ID_BLOCK_ID(idl, ID_BLOCK_NIDS(idl)++) = id;
                rc = idl_store( be, db, key, idl );
 
                idl_free( idl );
@@ -309,7 +315,7 @@ idl_insert_key(
        }
 
        /* regular block */
-       if ( ! INDIRECT_BLOCK( idl ) ) {
+       if ( ! ID_BLOCK_INDIRECT( idl ) ) {
                switch ( idl_insert( &idl, id, db->dbc_maxids ) ) {
                case 0:         /* id inserted - store the updated block */
                case 1:
@@ -336,11 +342,11 @@ idl_insert_key(
 
                        /* create the header indirect block */
                        idl = idl_alloc( 3 );
-                       idl->b_nmax = 3;
-                       idl->b_nids = INDBLOCK;
-                       idl->b_ids[0] = tmp->b_ids[0];
-                       idl->b_ids[1] = tmp2->b_ids[0];
-                       idl->b_ids[2] = NOID;
+                       ID_BLOCK_NMAX(idl) = 3;
+                       ID_BLOCK_NIDS(idl) = ID_BLOCK_INDIRECT_VALUE;
+                       ID_BLOCK_ID(idl, 0) = ID_BLOCK_ID(tmp, 0);
+                       ID_BLOCK_ID(idl, 1) = ID_BLOCK_ID(tmp2, 0);
+                       ID_BLOCK_ID(idl, 2) = NOID;
 
                        /* store it */
                        rc = idl_store( be, db, key, idl );
@@ -348,14 +354,14 @@ idl_insert_key(
                        /* store the first id block */
                        kstr = (char *) ch_malloc( key.dsize + 20 );
                        sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                           tmp->b_ids[0] );
+                           ID_BLOCK_ID(tmp, 0) );
                        k2.dptr = kstr;
                        k2.dsize = strlen( kstr ) + 1;
                        rc = idl_store( be, db, k2, tmp );
 
                        /* store the second id block */
                        sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                           tmp2->b_ids[0] );
+                           ID_BLOCK_ID(tmp2, 0) );
                        k2.dptr = kstr;
                        k2.dsize = strlen( kstr ) + 1;
                        rc = idl_store( be, db, k2, tmp2 );
@@ -379,7 +385,7 @@ idl_insert_key(
         */
 
        /* select the block to try inserting into */
-       for ( i = 0; idl->b_ids[i] != NOID && id > idl->b_ids[i]; i++ )
+       for ( i = 0; !ID_BLOCK_NOID(idl, i) && id > ID_BLOCK_ID(idl, i); i++ )
                ;       /* NULL */
        if ( i != 0 ) {
                i--;
@@ -390,7 +396,7 @@ idl_insert_key(
 
        /* get the block */
        kstr = (char *) ch_malloc( key.dsize + 20 );
-       sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, idl->b_ids[i] );
+       sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, ID_BLOCK_ID(idl, i) );
        k2.dptr = kstr;
        k2.dsize = strlen( kstr ) + 1;
        if ( (tmp = idl_fetch_one( be, db, k2 )) == NULL ) {
@@ -430,10 +436,10 @@ idl_insert_key(
                 */
 
                /* is there a next block? */
-               if ( !first && idl->b_ids[i + 1] != NOID ) {
+               if ( !first && !ID_BLOCK_NOID(idl, i + 1) ) {
                        /* read it in */
                        sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                           idl->b_ids[i + 1] );
+                           ID_BLOCK_ID(idl, i + 1) );
                        k2.dptr = kstr;
                        k2.dsize = strlen( kstr ) + 1;
                        if ( (tmp2 = idl_fetch_one( be, db, k2 )) == NULL ) {
@@ -476,7 +482,7 @@ idl_insert_key(
                 */
 
                /* count how many indirect blocks */
-               for ( j = 0; idl->b_ids[j] != NOID; j++ )
+               for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ )
                        ;       /* NULL */
 
                /* check it against all-id thresholed */
@@ -490,9 +496,9 @@ idl_insert_key(
                         */
 
                        /* delete all indirect blocks */
-                       for ( j = 0; idl->b_ids[j] != NOID; j++ ) {
-                               sprintf( kstr,"%c%s%ld", CONT_PREFIX, key.dptr,
-                                   idl->b_ids[j] );
+                       for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) {
+                               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
+                                   ID_BLOCK_ID(idl, j) );
                                k2.dptr = kstr;
                                k2.dsize = strlen( kstr ) + 1;
 
@@ -514,31 +520,35 @@ idl_insert_key(
                idl_free( tmp );
 
                /* create a new updated indirect header block */
-               tmp = idl_alloc( idl->b_nmax + 1 );
-               tmp->b_nids = INDBLOCK;
+               tmp = idl_alloc( ID_BLOCK_NMAX(idl) + 1 );
+               ID_BLOCK_NIDS(tmp) = ID_BLOCK_INDIRECT_VALUE;
                /* everything up to the split block */
-               SAFEMEMCPY( (char *) tmp->b_ids, (char *) idl->b_ids,
+               SAFEMEMCPY(
+                       (char *) &ID_BLOCK_ID(tmp, 0),
+                       (char *) &ID_BLOCK_ID(idl, 0),
                    i * sizeof(ID) );
                /* the two new blocks */
-               tmp->b_ids[i] = tmp2->b_ids[0];
-               tmp->b_ids[i + 1] = tmp3->b_ids[0];
+               ID_BLOCK_ID(tmp, i) = ID_BLOCK_ID(tmp2, 0);
+               ID_BLOCK_ID(tmp, i + 1) = ID_BLOCK_ID(tmp3, 0);
                /* everything after the split block */
-               SAFEMEMCPY( (char *) &tmp->b_ids[i + 2], (char *)
-                   &idl->b_ids[i + 1], (idl->b_nmax - i - 1) * sizeof(ID) );
+               SAFEMEMCPY(
+                       (char *) &ID_BLOCK_ID(tmp, i + 2),
+                       (char *) &ID_BLOCK_ID(idl, i + 1),
+                       (ID_BLOCK_NMAX(idl) - i - 1) * sizeof(ID) );
 
                /* store the header block */
                rc = idl_store( be, db, key, tmp );
 
                /* store the first id block */
                sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                   tmp2->b_ids[0] );
+                   ID_BLOCK_ID(tmp2, 0) );
                k2.dptr = kstr;
                k2.dsize = strlen( kstr ) + 1;
                rc = idl_store( be, db, k2, tmp2 );
 
                /* store the second id block */
                sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
-                   tmp3->b_ids[0] );
+                   ID_BLOCK_ID(tmp3, 0) );
                k2.dptr = kstr;
                k2.dsize = strlen( kstr ) + 1;
                rc = idl_store( be, db, k2, tmp3 );
@@ -563,45 +573,47 @@ idl_insert_key(
  */
 
 int
-idl_insert( IDList **idl, ID id, int maxids )
+idl_insert( ID_BLOCK **idl, ID id, int maxids )
 {
        unsigned int    i, j;
 
-       if ( ALLIDS( *idl ) ) {
+       if ( ID_BLOCK_ALLIDS( *idl ) ) {
                return( 2 );    /* already there */
        }
 
        /* is it already there? XXX bin search XXX */
-       for ( i = 0; i < (*idl)->b_nids && id > (*idl)->b_ids[i]; i++ ) {
+       for ( i = 0; i < ID_BLOCK_NIDS(*idl) && id > ID_BLOCK_ID(*idl, i); i++ ) {
                ;       /* NULL */
        }
-       if ( i < (*idl)->b_nids && (*idl)->b_ids[i] == id ) {
+       if ( i < ID_BLOCK_NIDS(*idl) && ID_BLOCK_ID(*idl, i) == id ) {
                return( 2 );    /* already there */
        }
 
        /* do we need to make room for it? */
-       if ( (*idl)->b_nids == (*idl)->b_nmax ) {
+       if ( ID_BLOCK_NIDS(*idl) == ID_BLOCK_NMAX(*idl) ) {
                /* make room or indicate block needs splitting */
-               if ( (*idl)->b_nmax == maxids ) {
+               if ( ID_BLOCK_NMAX(*idl) >= maxids ) {
                        return( 3 );    /* block needs splitting */
                }
 
-               (*idl)->b_nmax *= 2;
-               if ( (*idl)->b_nmax > maxids ) {
-                       (*idl)->b_nmax = maxids;
+               ID_BLOCK_NMAX(*idl) *= 2;
+               if ( ID_BLOCK_NMAX(*idl) > maxids ) {
+                       ID_BLOCK_NMAX(*idl) = maxids;
                }
-               *idl = (IDList *) ch_realloc( (char *) *idl,
-                   ((*idl)->b_nmax + 2) * sizeof(ID) );
+               *idl = (ID_BLOCK *) ch_realloc( (char *) *idl,
+                   (ID_BLOCK_NMAX(*idl) + ID_BLOCK_IDS_OFFSET) * sizeof(ID) );
        }
 
        /* make a slot for the new id */
-       for ( j = (*idl)->b_nids; j != i; j-- ) {
-               (*idl)->b_ids[j] = (*idl)->b_ids[j-1];
+       for ( j = ID_BLOCK_NIDS(*idl); j != i; j-- ) {
+               ID_BLOCK_ID(*idl, j) = ID_BLOCK_ID(*idl, j-1);
        }
-       (*idl)->b_ids[i] = id;
-       (*idl)->b_nids++;
-       (void) memset( (char *) &(*idl)->b_ids[(*idl)->b_nids], '\0',
-           ((*idl)->b_nmax - (*idl)->b_nids) * sizeof(ID) );
+       ID_BLOCK_ID(*idl, i) = id;
+       ID_BLOCK_NIDS(*idl)++;
+       (void) memset(
+               (char *) &ID_BLOCK_ID((*idl), ID_BLOCK_NIDS(*idl)),
+               '\0',
+           (ID_BLOCK_NMAX(*idl) - ID_BLOCK_NIDS(*idl)) * sizeof(ID) );
 
        return( i == 0 ? 1 : 0 );       /* inserted - first id changed or not */
 }
@@ -615,7 +627,7 @@ idl_delete_key (
 )
 {
        Datum  k2;
-       IDList *idl, *tmp;
+       ID_BLOCK *idl, *tmp;
        unsigned i;
        int j, nids;
        char    *kstr;
@@ -626,16 +638,21 @@ idl_delete_key (
                return -1;
        }
 
-       if ( ! INDIRECT_BLOCK( idl ) )
+       if ( ! ID_BLOCK_INDIRECT( idl ) )
        {
-               for ( i=0; i < idl->b_nids; i++ )
+               for ( i=0; i < ID_BLOCK_NIDS(idl); i++ )
                {
-                       if ( idl->b_ids[i] == id )
+                       if ( ID_BLOCK_ID(idl, i) == id )
                        {
-                               memcpy ( &idl->b_ids[i], &idl->b_ids[i+1], sizeof(ID)*(idl->b_nids-(i+1)));
-                               idl->b_ids[idl->b_nids-1] = NOID;
-                               idl->b_nids--;
-                               if ( idl->b_nids )
+                               SAFEMEMCPY (
+                                       &ID_BLOCK_ID(idl, i),
+                                       &ID_BLOCK_ID(idl, i+1),
+                                       (ID_BLOCK_NIDS(idl)-(i+1)) * sizeof(ID) );
+
+                               ID_BLOCK_ID(idl, ID_BLOCK_NIDS(idl)-1) = NOID;
+                               ID_BLOCK_NIDS(idl)--;
+
+                               if ( ID_BLOCK_NIDS(idl) )
                                        idl_store( be, db, key, idl );
                                else
                                        ldbm_cache_delete( db, key );
@@ -649,13 +666,14 @@ idl_delete_key (
        /* We have to go through an indirect block and find the ID
           in the list of IDL's
           */
-       for ( nids = 0; idl->b_ids[nids] != NOID; nids++ )
+       for ( nids = 0; !ID_BLOCK_NOID(idl, nids); nids++ )
                ;       /* NULL */
        kstr = (char *) ch_malloc( key.dsize + 20 );
-       for ( j = 0; idl->b_ids[j] != NOID; j++ ) 
+
+       for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) 
        {
                ldbm_datum_init( k2 );
-               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, idl->b_ids[j] );
+               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, ID_BLOCK_ID(idl, j) );
                k2.dptr = kstr;
                k2.dsize = strlen( kstr ) + 1;
 
@@ -667,20 +685,26 @@ idl_delete_key (
                /*
                   Now try to find the ID in tmp
                */
-               for ( i=0; i < tmp->b_nids; i++ )
+               for ( i=0; i < ID_BLOCK_NIDS(tmp); i++ )
                {
-                       if ( tmp->b_ids[i] == id )
+                       if ( ID_BLOCK_ID(tmp, i) == id )
                        {
-                               memcpy ( &tmp->b_ids[i], &tmp->b_ids[i+1], sizeof(ID)*(tmp->b_nids-(i+1)));
-                               tmp->b_ids[tmp->b_nids-1] = NOID;
-                               tmp->b_nids--;
-                               if ( tmp->b_nids )
+                               SAFEMEMCPY(
+                                       &ID_BLOCK_ID(tmp, i),
+                                       &ID_BLOCK_ID(tmp, i+1),
+                                       (ID_BLOCK_NIDS(tmp)-(i+1)) * sizeof(ID));
+                               ID_BLOCK_ID(tmp, ID_BLOCK_NIDS(tmp)-1 ) = NOID;
+                               ID_BLOCK_NIDS(tmp)--;
+                               if ( ID_BLOCK_NIDS(tmp) )
                                        idl_store ( be, db, k2, tmp );
                                else
                                {
                                        ldbm_cache_delete( db, k2 );
-                                       memcpy ( &idl->b_ids[j], &idl->b_ids[j+1], sizeof(ID)*(nids-(j+1)));
-                                       idl->b_ids[nids-1] = NOID;
+                                       SAFEMEMCPY(
+                                               &ID_BLOCK_ID(idl, j),
+                                               &ID_BLOCK_ID(idl, j+1),
+                                               (nids-(j+1)) * sizeof(ID));
+                                       ID_BLOCK_ID(idl, nids-1) = NOID;
                                        nids--;
                                        if ( ! nids )
                                                ldbm_cache_delete( db, key );
@@ -694,64 +718,67 @@ idl_delete_key (
        return -1;
 }
 
-static IDList *
-idl_dup( IDList *idl )
+static ID_BLOCK *
+idl_dup( ID_BLOCK *idl )
 {
-       IDList  *new;
+       ID_BLOCK        *new;
 
        if ( idl == NULL ) {
                return( NULL );
        }
 
-       new = idl_alloc( idl->b_nmax );
-       SAFEMEMCPY( (char *) new, (char *) idl, (idl->b_nmax + 2)
-           * sizeof(ID) );
+       new = idl_alloc( ID_BLOCK_NMAX(idl) );
+
+       SAFEMEMCPY(
+               (char *) new,
+               (char *) idl,
+               (ID_BLOCK_NMAX(idl) + ID_BLOCK_IDS_OFFSET) * sizeof(ID) );
 
        return( new );
 }
 
-static IDList *
-idl_min( IDList *a, IDList *b )
+static ID_BLOCK *
+idl_min( ID_BLOCK *a, ID_BLOCK *b )
 {
-       return( a->b_nids > b->b_nids ? b : a );
+       return( ID_BLOCK_NIDS(a) > ID_BLOCK_NIDS(b) ? b : a );
 }
 
 /*
  * idl_intersection - return a intersection b
  */
 
-IDList *
+ID_BLOCK *
 idl_intersection(
     Backend    *be,
-    IDList     *a,
-    IDList     *b
+    ID_BLOCK   *a,
+    ID_BLOCK   *b
 )
 {
        unsigned int    ai, bi, ni;
-       IDList          *n;
+       ID_BLOCK                *n;
 
        if ( a == NULL || b == NULL ) {
                return( NULL );
        }
-       if ( ALLIDS( a ) ) {
+       if ( ID_BLOCK_ALLIDS( a ) ) {
                return( idl_dup( b ) );
        }
-       if ( ALLIDS( b ) ) {
+       if ( ID_BLOCK_ALLIDS( b ) ) {
                return( idl_dup( a ) );
        }
 
        n = idl_dup( idl_min( a, b ) );
 
-       for ( ni = 0, ai = 0, bi = 0; ai < a->b_nids; ai++ ) {
-               for ( ; bi < b->b_nids && b->b_ids[bi] < a->b_ids[ai]; bi++ )
+       for ( ni = 0, ai = 0, bi = 0; ai < ID_BLOCK_NIDS(a); ai++ ) {
+               for ( ; bi < ID_BLOCK_NIDS(b) && ID_BLOCK_ID(b, bi) < ID_BLOCK_ID(a, ai); bi++ )
                        ;       /* NULL */
 
-               if ( bi == b->b_nids ) {
+               if ( bi == ID_BLOCK_NIDS(b) ) {
                        break;
                }
 
-               if ( b->b_ids[bi] == a->b_ids[ai] ) {
-                       n->b_ids[ni++] = a->b_ids[ai];
+               if ( ID_BLOCK_ID(b, bi) == ID_BLOCK_ID(a, ai) ) {
+                       ID_BLOCK_ID(n, ni++) = ID_BLOCK_ID(a, ai);
                }
        }
 
@@ -759,7 +786,7 @@ idl_intersection(
                idl_free( n );
                return( NULL );
        }
-       n->b_nids = ni;
+       ID_BLOCK_NIDS(n) = ni;
 
        return( n );
 }
@@ -768,15 +795,15 @@ idl_intersection(
  * idl_union - return a union b
  */
 
-IDList *
+ID_BLOCK *
 idl_union(
     Backend    *be,
-    IDList     *a,
-    IDList     *b
+    ID_BLOCK   *a,
+    ID_BLOCK   *b
 )
 {
        unsigned int    ai, bi, ni;
-       IDList          *n;
+       ID_BLOCK                *n;
 
        if ( a == NULL ) {
                return( idl_dup( b ) );
@@ -784,36 +811,38 @@ idl_union(
        if ( b == NULL ) {
                return( idl_dup( a ) );
        }
-       if ( ALLIDS( a ) || ALLIDS( b ) ) {
+       if ( ID_BLOCK_ALLIDS( a ) || ID_BLOCK_ALLIDS( b ) ) {
                return( idl_allids( be ) );
        }
 
-       if ( b->b_nids < a->b_nids ) {
+       if ( ID_BLOCK_NIDS(b) < ID_BLOCK_NIDS(a) ) {
                n = a;
                a = b;
                b = n;
        }
 
-       n = idl_alloc( a->b_nids + b->b_nids );
+       n = idl_alloc( ID_BLOCK_NIDS(a) + ID_BLOCK_NIDS(b) );
+
+       for ( ni = 0, ai = 0, bi = 0; ai < ID_BLOCK_NIDS(a) && bi < ID_BLOCK_NIDS(b); ) {
+               if ( ID_BLOCK_ID(a, ai) < ID_BLOCK_ID(b, bi) ) {
+                       ID_BLOCK_ID(n, ni++) = ID_BLOCK_ID(a, ai++);
+
+               } else if ( ID_BLOCK_ID(b, bi) < ID_BLOCK_ID(a, ai) ) {
+                       ID_BLOCK_ID(n, ni++) = ID_BLOCK_ID(b, bi++);
 
-       for ( ni = 0, ai = 0, bi = 0; ai < a->b_nids && bi < b->b_nids; ) {
-               if ( a->b_ids[ai] < b->b_ids[bi] ) {
-                       n->b_ids[ni++] = a->b_ids[ai++];
-               } else if ( b->b_ids[bi] < a->b_ids[ai] ) {
-                       n->b_ids[ni++] = b->b_ids[bi++];
                } else {
-                       n->b_ids[ni++] = a->b_ids[ai];
+                       ID_BLOCK_ID(n, ni++) = ID_BLOCK_ID(a, ai);
                        ai++, bi++;
                }
        }
 
-       for ( ; ai < a->b_nids; ai++ ) {
-               n->b_ids[ni++] = a->b_ids[ai];
+       for ( ; ai < ID_BLOCK_NIDS(a); ai++ ) {
+               ID_BLOCK_ID(n, ni++) = ID_BLOCK_ID(a, ai);
        }
-       for ( ; bi < b->b_nids; bi++ ) {
-               n->b_ids[ni++] = b->b_ids[bi];
+       for ( ; bi < ID_BLOCK_NIDS(b); bi++ ) {
+               ID_BLOCK_ID(n, ni++) = ID_BLOCK_ID(b, bi);
        }
-       n->b_nids = ni;
+       ID_BLOCK_NIDS(n) = ni;
 
        return( n );
 }
@@ -822,45 +851,47 @@ idl_union(
  * idl_notin - return a intersection ~b (or a minus b)
  */
 
-IDList *
+ID_BLOCK *
 idl_notin(
     Backend    *be,
-    IDList     *a,
-    IDList     *b
+    ID_BLOCK   *a,
+    ID_BLOCK   *b
 )
 {
        unsigned int    ni, ai, bi;
-       IDList          *n;
+       ID_BLOCK                *n;
 
        if ( a == NULL ) {
                return( NULL );
        }
-       if ( b == NULL || ALLIDS( b )) {
+       if ( b == NULL || ID_BLOCK_ALLIDS( b )) {
                return( idl_dup( a ) );
        }
 
-       if ( ALLIDS( a ) ) {
+       if ( ID_BLOCK_ALLIDS( a ) ) {
                n = idl_alloc( SLAPD_LDBM_MIN_MAXIDS );
                ni = 0;
 
-               for ( ai = 1, bi = 0; ai < a->b_nids && ni < n->b_nmax &&
-                   bi < b->b_nmax; ai++ ) {
-                       if ( b->b_ids[bi] == ai ) {
+               for ( ai = 1, bi = 0;
+                       ai < ID_BLOCK_NIDS(a) && ni < ID_BLOCK_NMAX(n) && bi < ID_BLOCK_NMAX(b);
+                       ai++ )
+               {
+                       if ( ID_BLOCK_ID(b, bi) == ai ) {
                                bi++;
                        } else {
-                               n->b_ids[ni++] = ai;
+                               ID_BLOCK_ID(n, ni++) = ai;
                        }
                }
 
-               for ( ; ai < a->b_nids && ni < n->b_nmax; ai++ ) {
-                       n->b_ids[ni++] = ai;
+               for ( ; ai < ID_BLOCK_NIDS(a) && ni < ID_BLOCK_NMAX(n); ai++ ) {
+                       ID_BLOCK_ID(n, ni++) = ai;
                }
 
-               if ( ni == n->b_nmax ) {
+               if ( ni == ID_BLOCK_NMAX(n) ) {
                        idl_free( n );
                        return( idl_allids( be ) );
                } else {
-                       n->b_nids = ni;
+                       ID_BLOCK_NIDS(n) = ni;
                        return( n );
                }
        }
@@ -868,60 +899,62 @@ idl_notin(
        n = idl_dup( a );
 
        ni = 0;
-       for ( ai = 0, bi = 0; ai < a->b_nids; ai++ ) {
-               for ( ; bi < b->b_nids && b->b_ids[bi] < a->b_ids[ai];
-                   bi++ ) {
+       for ( ai = 0, bi = 0; ai < ID_BLOCK_NIDS(a); ai++ ) {
+               for ( ;
+                       bi < ID_BLOCK_NIDS(b) && ID_BLOCK_ID(b, bi) < ID_BLOCK_ID(a, ai);
+                   bi++ )
+               {
                        ;       /* NULL */
                }
 
-               if ( bi == b->b_nids ) {
+               if ( bi == ID_BLOCK_NIDS(b) ) {
                        break;
                }
 
-               if ( b->b_ids[bi] != a->b_ids[ai] ) {
-                       n->b_ids[ni++] = a->b_ids[ai];
+               if ( ID_BLOCK_ID(b, bi) != ID_BLOCK_ID(a, ai) ) {
+                       ID_BLOCK_ID(n, ni++) = ID_BLOCK_ID(a, ai);
                }
        }
 
-       for ( ; ai < a->b_nids; ai++ ) {
-               n->b_ids[ni++] = a->b_ids[ai];
+       for ( ; ai < ID_BLOCK_NIDS(a); ai++ ) {
+               ID_BLOCK_ID(n, ni++) = ID_BLOCK_ID(a, ai);
        }
-       n->b_nids = ni;
+       ID_BLOCK_NIDS(n) = ni;
 
        return( n );
 }
 
 ID
-idl_firstid( IDList *idl )
+idl_firstid( ID_BLOCK *idl )
 {
-       if ( idl == NULL || idl->b_nids == 0 ) {
+       if ( idl == NULL || ID_BLOCK_NIDS(idl) == 0 ) {
                return( NOID );
        }
 
-       if ( ALLIDS( idl ) ) {
-               return( idl->b_nids == 1 ? NOID : 1 );
+       if ( ID_BLOCK_ALLIDS( idl ) ) {
+               return( ID_BLOCK_NIDS(idl) == 1 ? NOID : 1 );
        }
 
-       return( idl->b_ids[0] );
+       return( ID_BLOCK_ID(idl, 0) );
 }
 
 ID
-idl_nextid( IDList *idl, ID id )
+idl_nextid( ID_BLOCK *idl, ID id )
 {
        unsigned int    i;
 
-       if ( ALLIDS( idl ) ) {
-               return( ++id < idl->b_nids ? id : NOID );
+       if ( ID_BLOCK_ALLIDS( idl ) ) {
+               return( ++id < ID_BLOCK_NIDS(idl) ? id : NOID );
        }
 
-       for ( i = 0; i < idl->b_nids && idl->b_ids[i] < id; i++ ) {
+       for ( i = 0; i < ID_BLOCK_NIDS(idl) && ID_BLOCK_ID(idl, i) < id; i++ ) {
                ;       /* NULL */
        }
        i++;
 
-       if ( i >= idl->b_nids ) {
+       if ( i >= ID_BLOCK_NIDS(idl) ) {
                return( NOID );
        } else {
-               return( idl->b_ids[i] );
+               return( ID_BLOCK_ID(idl, i) );
        }
 }
index 2d858e133a9425dde1d4cb69e167f0e214b5d875..b87bf51c2eeafba5531ba8c09c370ea7dec1c33e 100644 (file)
@@ -83,7 +83,7 @@ index_add_mods(
        return( 0 );
 }
 
-IDList *
+ID_BLOCK *
 index_read(
     Backend    *be,
     char       *type,
@@ -93,7 +93,7 @@ index_read(
 {
        struct dbcache  *db;
        Datum           key;
-       IDList          *idl;
+       ID_BLOCK                *idl;
        int             indexmask, syntax;
        char            prefix;
        char            *realval, *tmpval;
@@ -110,7 +110,7 @@ index_read(
                idl =  idl_allids( be );
                Debug( LDAP_DEBUG_TRACE,
                    "<= index_read %lu candidates (allids - not indexed)\n",
-                   idl ? idl->b_nids : 0, 0, 0 );
+                   idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
                return( idl );
        }
 
@@ -150,7 +150,7 @@ index_read(
        ldbm_cache_close( be, db );
 
        Debug( LDAP_DEBUG_TRACE, "<= index_read %lu candidates\n",
-           idl ? idl->b_nids : 0, 0, 0 );
+           idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
        return( idl );
 }
 
@@ -166,7 +166,7 @@ add_value(
 {
        int     rc;
        Datum   key;
-       IDList  *idl;
+       ID_BLOCK        *idl;
        char    prefix;
        char    *realval, *tmpval, *s;
        char    buf[BUFSIZ];
index b9fd37bbdc582c04e4610399558b9c2f986a5b42..a3af6a4a0fd00d33c4b9481aa1730d6675fa0e3a 100644 (file)
@@ -69,7 +69,7 @@ Entry * dn2entry_w LDAP_P(( Backend *be, char *dn, char **matched ));
  * filterindex.c
  */
 
-IDList * filter_candidates LDAP_P(( Backend *be, Filter *f ));
+ID_BLOCK * filter_candidates LDAP_P(( Backend *be, Filter *f ));
 
 /*
  * id2children.c
@@ -93,18 +93,18 @@ Entry * id2entry_w LDAP_P(( Backend *be, ID id ));
  * idl.c
  */
 
-IDList * idl_alloc LDAP_P(( int nids ));
-IDList * idl_allids LDAP_P(( Backend *be ));
-void idl_free LDAP_P(( IDList *idl ));
-IDList * idl_fetch LDAP_P(( Backend *be, struct dbcache *db, Datum key ));
+ID_BLOCK * idl_alloc LDAP_P(( int nids ));
+ID_BLOCK * idl_allids LDAP_P(( Backend *be ));
+void idl_free LDAP_P(( ID_BLOCK *idl ));
+ID_BLOCK * idl_fetch LDAP_P(( Backend *be, struct dbcache *db, Datum key ));
 int idl_insert_key LDAP_P(( Backend *be, struct dbcache *db, Datum key, ID id ));
-int idl_insert LDAP_P(( IDList **idl, ID id, int maxids ));
+int idl_insert LDAP_P(( ID_BLOCK **idl, ID id, int maxids ));
 int idl_delete_key LDAP_P(( Backend *be, struct dbcache *db, Datum key, ID id ));
-IDList * idl_intersection LDAP_P(( Backend *be, IDList *a, IDList *b ));
-IDList * idl_union LDAP_P(( Backend *be, IDList *a, IDList *b ));
-IDList * idl_notin LDAP_P(( Backend *be, IDList *a, IDList *b ));
-ID idl_firstid LDAP_P(( IDList *idl ));
-ID idl_nextid LDAP_P(( IDList *idl, ID id ));
+ID_BLOCK * idl_intersection LDAP_P(( Backend *be, ID_BLOCK *a, ID_BLOCK *b ));
+ID_BLOCK * idl_union LDAP_P(( Backend *be, ID_BLOCK *a, ID_BLOCK *b ));
+ID_BLOCK * idl_notin LDAP_P(( Backend *be, ID_BLOCK *a, ID_BLOCK *b ));
+ID idl_firstid LDAP_P(( ID_BLOCK *idl ));
+ID idl_nextid LDAP_P(( ID_BLOCK *idl, ID id ));
 
 /*
  * index.c
@@ -112,7 +112,7 @@ ID idl_nextid LDAP_P(( IDList *idl, ID id ));
 
 int index_add_entry LDAP_P(( Backend *be, Entry *e ));
 int index_add_mods LDAP_P(( Backend *be, LDAPMod *mods, ID id ));
-IDList * index_read LDAP_P(( Backend *be, char *type, int indextype, char *val ));
+ID_BLOCK * index_read LDAP_P(( Backend *be, char *type, int indextype, char *val ));
 int index_add_values LDAP_P(( Backend *be, char *type, struct berval **vals, ID  id ));
 
 /*
index 4fb6c6a17a70d757ea93e5af324837fea491e9ac..167b498a1918e324cfbe9e85afdf3638eb966a54 100644 (file)
@@ -11,9 +11,9 @@
 #include "back-ldbm.h"
 #include "proto-back-ldbm.h"
 
-static IDList  *base_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, int *err);
-static IDList  *onelevel_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, int *err);
-static IDList  *subtree_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, Entry *e, int *err, int lookupbase);
+static ID_BLOCK        *base_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, int *err);
+static ID_BLOCK        *onelevel_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, int *err);
+static ID_BLOCK        *subtree_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, Entry *e, int *err, int lookupbase);
 
 #define GRABSIZE       BUFSIZ
 
@@ -45,7 +45,7 @@ ldbm_back_search(
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        int             err;
        time_t          stoptime;
-       IDList          *candidates;
+       ID_BLOCK                *candidates;
        ID              id;
        Entry           *e;
        Attribute       *ref;
@@ -311,7 +311,7 @@ ldbm_back_search(
        return( 0 );
 }
 
-static IDList *
+static ID_BLOCK *
 base_candidates(
     Backend    *be,
     Connection *conn,
@@ -327,7 +327,7 @@ base_candidates(
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        int             rc;
        ID              id;
-       IDList          *idl;
+       ID_BLOCK                *idl;
        Entry           *e;
 
        Debug(LDAP_DEBUG_TRACE, "base_candidates: base: \"%s\"\n", base, 0, 0);
@@ -352,7 +352,7 @@ base_candidates(
        return( idl );
 }
 
-static IDList *
+static ID_BLOCK *
 onelevel_candidates(
     Backend    *be,
     Connection *conn,
@@ -369,7 +369,7 @@ onelevel_candidates(
        Entry           *e = NULL;
        Filter          *f;
        char            buf[20];
-       IDList          *candidates;
+       ID_BLOCK                *candidates;
 
        Debug(LDAP_DEBUG_TRACE, "onelevel_candidates: base: \"%s\"\n", base, 0, 0);
 
@@ -415,7 +415,7 @@ onelevel_candidates(
        return( candidates );
 }
 
-static IDList *
+static ID_BLOCK *
 subtree_candidates(
     Backend    *be,
     Connection *conn,
@@ -432,7 +432,7 @@ subtree_candidates(
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        Filter          *f, **filterarg_ptr;
-       IDList          *candidates;
+       ID_BLOCK                *candidates;
 
        Debug(LDAP_DEBUG_TRACE, "subtree_candidates: base: \"%s\" %s\n",
                base ? base : "NULL", lookupbase ? "lookupbase" : "", 0);
index 31d43491aeda49bfcc6f4dfb0567c9fd2ae034bb..afdd148ee0c6b9222c7d7da4c66be390faa58511 100644 (file)
@@ -42,7 +42,7 @@ main( int argc, char **argv )
        Datum           savekey, key, data, last;
        char            *fname;
        ID              id;
-       IDList          *idl;
+       ID_BLOCK                *idl;
        Backend         *tbe;
        int             i;
        char            *tailorfile;
@@ -127,7 +127,7 @@ main( int argc, char **argv )
                        get_keydata( stdin, buf[1], &key, NULL );
                        if ( (idl = idl_fetch( be, dbc, key )) != NULL ) {
                                data.dptr = (char *) idl;
-                               data.dsize = (idl->b_nmax + 1) * sizeof(ID);
+                               data.dsize = (ID_BLOCK_NMAX(idl) + 1) * sizeof(ID);
                                print_entry( stdout, buf[1], &key, "key: ",
                                    &data, "data:\n" );
                        }
@@ -266,7 +266,7 @@ main( int argc, char **argv )
 
                        get_keydata( stdin, buf[1], &key, &data );
 
-                       idl = (IDList *) data.dptr;
+                       idl = (ID_BLOCK *) data.dptr;
                        for ( id = idl_firstid( idl ); id != NOID;
                            id = idl_nextid( idl, id ) ) {
                                if ( idl_insert_key( be, dbc, key, id )
@@ -390,7 +390,7 @@ get_idlist( FILE *fp, Datum *data )
 {
        char    buf[20];
        int     i, j, fd, tty;
-       IDList  *p;
+       ID_BLOCK        *p;
        int     psize, pmax;
        int     nmax, nids;
 
@@ -415,7 +415,7 @@ get_idlist( FILE *fp, Datum *data )
 
                if ( psize + sizeof(ID) > pmax ) {
                        pmax += BUFSIZ;
-                       p = (IDList *) myrealloc( (char *) p, pmax );
+                       p = (ID_BLOCK *) myrealloc( (char *) p, pmax );
                }
 
                if ( strncmp( buf, "nids=0", 6 ) == 0 ) {
@@ -423,7 +423,7 @@ get_idlist( FILE *fp, Datum *data )
                        continue;
                }
 
-               p->b_ids[i++] = atol( buf );
+               ID_BLOCK_ID(p,i++) = atol( buf );
                psize += sizeof(ID);
        }
        if ( nmax == 0 ) {
@@ -440,19 +440,19 @@ get_idlist( FILE *fp, Datum *data )
                }
        }
        if ( i > 0 ) {
-               p->b_nmax = nmax;
+               ID_BLOCK_NMAX(p) = nmax;
                if ( nids != 0 ) {
-                       p->b_nids = 0;
-                       p->b_ids[i] = NOID;
+                       ID_BLOCK_NIDS(p) = 0;
+                       ID_BLOCK_ID(p,i) = NOID;
                } else {
-                       p->b_nids = i;
+                       ID_BLOCK_NIDS(p) = i;
                }
 
-               qsort( (void *) p->b_ids, i, sizeof(ID), dnid_cmp );
+               qsort( (void *) &ID_BLOCK_ID(p, 0), i, sizeof(ID), dnid_cmp );
        }
 
        data->dptr = (char *) p;
-       data->dsize = (nmax + 2) * sizeof(ID);
+       data->dsize = (nmax + ID_BLOCK_IDS_OFFSET) * sizeof(ID);
 }
 
 static void
@@ -630,7 +630,7 @@ print_entry(
 )
 {
        ID      id;
-       IDList  *idl;
+       ID_BLOCK        *idl;
        int     i;
        char    msg[2];
 
@@ -677,22 +677,22 @@ print_entry(
                        fprintf( fp, "%s%s (len %d)\n", klabel, key->dptr,
                            key->dsize );
                if ( data != NULL ) {
-                       idl = (IDList *) data->dptr;
+                       idl = (ID_BLOCK *) data->dptr;
 
                        if ( dlabel )
                                fprintf( fp, "%s\tnmax=%ld\n\tncur=%ld\n", dlabel,
-                                   idl->b_nmax, idl->b_nids );
+                                   ID_BLOCK_NMAX(idl), ID_BLOCK_NIDS(idl) );
 
-                       if ( INDIRECT_BLOCK( idl ) ) {
-                               for ( i = 0; idl->b_ids[i] != NOID; i++ ) {
-                                       fprintf( fp, "\t%ld\n", idl->b_ids[i] );
+                       if ( ID_BLOCK_INDIRECT( idl ) ) {
+                               for ( i = 0; !ID_BLOCK_NOID(idl, i); i++ ) {
+                                       fprintf( fp, "\t%ld\n", ID_BLOCK_ID(idl, i) );
                                }
-                       } else if ( ALLIDS( idl ) ) {
+                       } else if ( ID_BLOCK_ALLIDS( idl ) ) {
                                fprintf( fp, "\tALLIDS (1..%ld)\n",
-                                   idl->b_nids - 1 );
+                                   ID_BLOCK_NIDS(idl) - 1 );
                        } else {
-                               for ( i = 0; i < idl->b_nids; i++ ) {
-                                       fprintf( fp, "\t%ld\n", idl->b_ids[i] );
+                               for ( i = 0; i < ID_BLOCK_NIDS(idl); i++ ) {
+                                       fprintf( fp, "\t%ld\n", ID_BLOCK_ID(idl,i) );
                                }
                        }
                }