/* make a slot for the new id */
SAFEMEMCPY( &ID_BLOCK_ID(*idl, i), &ID_BLOCK_ID(*idl, i+1),
- ID_BLOCKS_NIDS(*idl) - i );
+ ID_BLOCK_NIDS(*idl) - i );
ID_BLOCK_ID(*idl, i) = id;
ID_BLOCK_NIDS(*idl)++;
* NIDS > 1 return 1
* otherwise return NOID
* otherwise return first ID
+ *
+ * cursor is set to 1
*/
ID
-bdb2i_idl_firstid( ID_BLOCK *idl )
+bdb2i_idl_firstid( ID_BLOCK *idl, ID *cursor )
{
+ *cursor = 1;
+
if ( idl == NULL || ID_BLOCK_NIDS(idl) == 0 ) {
return( NOID );
}
/* return next ID after id
- * if ALLIDS block, increment id.
+ * if ALLIDS block, cursor is id
+ * increment id
* if id < NIDS return id
* otherwise NOID.
- * otherwise SEARCH for next id (ugh!)
+ * otherwise cursor is index into block
+ * if index < nids
+ * return id at index then increment
*/
ID
-bdb2i_idl_nextid( ID_BLOCK *idl, ID id )
+bdb2i_idl_nextid( ID_BLOCK *idl, ID *cursor )
{
- unsigned int i;
-
if ( ID_BLOCK_ALLIDS( idl ) ) {
- return( ++id < ID_BLOCK_NIDS(idl) ? id : NOID );
- }
-
- for ( i = 0; i < ID_BLOCK_NIDS(idl) && ID_BLOCK_ID(idl, i) <= id; i++ ) {
- ; /* NULL */
+ if( ++(*cursor) < ID_BLOCK_NIDS(idl) ) {
+ return *cursor;
+ } else {
+ return NOID;
+ }
}
- if ( i >= ID_BLOCK_NIDS(idl) ) {
- return( NOID );
- } else {
- return( ID_BLOCK_ID(idl, i) );
+ if ( *cursor < ID_BLOCK_NIDS(idl) ) {
+ return ID_BLOCK_ID(idl, (*cursor)++);
}
+ return NOID;
}
ID_BLOCK * bdb2i_idl_intersection LDAP_P(( BackendDB *be, ID_BLOCK *a, ID_BLOCK *b ));
ID_BLOCK * bdb2i_idl_union LDAP_P(( BackendDB *be, ID_BLOCK *a, ID_BLOCK *b ));
ID_BLOCK * bdb2i_idl_notin LDAP_P(( BackendDB *be, ID_BLOCK *a, ID_BLOCK *b ));
-ID bdb2i_idl_firstid LDAP_P(( ID_BLOCK *idl ));
-ID bdb2i_idl_nextid LDAP_P(( ID_BLOCK *idl, ID id ));
+ID bdb2i_idl_firstid LDAP_P(( ID_BLOCK *idl, ID *cursor ));
+ID bdb2i_idl_nextid LDAP_P(( ID_BLOCK *idl, ID *cursor ));
/*
* index.c
char *text;
time_t stoptime;
ID_BLOCK *candidates;
- ID id;
+ ID id, cursor;
Entry *e;
struct berval **v2refs = NULL;
Entry *matched = NULL;
goto done;
}
- for ( id = bdb2i_idl_firstid( candidates ); id != NOID;
- id = bdb2i_idl_nextid( candidates, id ) )
+ for ( id = bdb2i_idl_firstid( candidates, &cursor ); id != NOID;
+ id = bdb2i_idl_nextid( candidates, &cursor ) )
{
int scopeok = 0;