returned from the backend.
/* Our entries are almost always contiguous blocks, so a single
* free() on the Entry pointer suffices. The exception is when
* an entry has been modified, in which case the attr list will
- * have been alloc'd separately.
+ * have been alloc'd separately and its address will no longer
+ * be a constant offset from (e).
*/
- if( (void *) e->e_attrs < (void *) e
- || (void *) e->e_attrs > e->e_private )
+ if( (void *) e->e_attrs != (void *) (e+1))
{
attrs_free(e->e_attrs);
}
return 0;
}
+int bdb_entry_release(
+ BackendDB *be,
+ Connection *c,
+ Operation *o,
+ Entry *e,
+ int rw )
+{
+ /* A tool will call this with NULL Connection and Operation
+ * pointers. We don't need to do anything in that case,
+ * because the tool is getting entries into a realloc'd
+ * buffer.
+ */
+ if (c && o)
+ return bdb_entry_return(be, e);
+}
} else {
flags |= DB_INIT_CDB;
bdb->bi_txn_cp = 0;
- bdb->bi_dbenv->set_lk_detect(bdb->bi_dbenv, DB_LOCK_DEFAULT);
}
bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0] );
bi->bi_acl_attribute = bdb_attribute;
bi->bi_chk_referrals = bdb_referrals;
- bi->bi_entry_release_rw = 0;
+ bi->bi_entry_release_rw = bdb_entry_release;
/*
* hooks for slap tools
* entry.c
*/
int bdb_entry_return( BackendDB *be, Entry *e );
+int bdb_entry_release( BackendDB *, Connection *, Operation *, Entry *, int );
/*
* error.c
* All we have to do is add the buffer address to all of the
* stored offsets. We also must lookup the stored attribute names
* to get AttributeDescriptions. To detect if the attributes of
- * an Entry are later modified, we also store the address of the
- * end of this block in e_private.
+ * an Entry are later modified, we note that e->e_attr is always
+ * a constant offset from (e).
*
* Note: everything is stored in a single contiguous block, so
* you can not free individual attributes or names from this
"entry_decode: \"%s\"\n",
x->e_dn, 0, 0 );
#endif
- x->e_private = bv->bv_val + bv->bv_len;
+ x->e_private = NULL;
if (x->e_attrs)
x->e_attrs = (Attribute *)((long)x->e_attrs+base);
for (a=x->e_attrs; a; a=a->a_next) {
}
data = entry2str( e, &len );
- entry_free( e );
+ be_entry_release_r( be, 0L, 0L, e );
if ( data == NULL ) {
printf("# bad data for entry id=%08lx\n\n", (long) id );