/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
goto fail;
}
+#define bvcasematch(bv1, bv2) ( ((bv1)->bv_len == (bv2)->bv_len) && (strncasecmp((bv1)->bv_val, (bv2)->bv_val, (bv1)->bv_len) == 0) )
+
/* Make sure all attributes with multiple values are contiguous */
if ( checkvals ) {
int j, k;
for (i=0; i<lines; i++) {
for ( j=i+1; j<lines; j++ ) {
- if ( bvmatch( type+i, type+j )) {
+ if ( bvcasematch( type+i, type+j )) {
/* out of order, move intervening attributes down */
if ( j != i+1 ) {
bv = vals[j];
for ( i=0; i<=lines; i++ ) {
ad_prev = ad;
- if ( !ad || ( i<lines && !bvmatch( type+i, &ad->ad_cname ))) {
+ if ( !ad || ( i<lines && !bvcasematch( type+i, &ad->ad_cname ))) {
ad = NULL;
rc = slap_bv2ad( type+i, &ad, &text );
/* e_private must be freed by the caller */
assert( e->e_private == NULL );
+ e->e_id = 0;
+
/* free DNs */
if ( !BER_BVISNULL( &e->e_name ) ) {
free( e->e_name.bv_val );
+ BER_BVZERO( &e->e_name );
}
if ( !BER_BVISNULL( &e->e_nname ) ) {
free( e->e_nname.bv_val );
+ BER_BVZERO( &e->e_nname );
}
if ( !BER_BVISNULL( &e->e_bv ) ) {
free( e->e_bv.bv_val );
+ BER_BVZERO( &e->e_bv );
}
/* free attributes */
- attrs_free( e->e_attrs );
+ if ( e->e_attrs ) {
+ attrs_free( e->e_attrs );
+ e->e_attrs = NULL;
+ }
- memset(e, 0, sizeof(Entry));
+ e->e_ocflags = 0;
}
void
ldap_pvt_thread_mutex_unlock( &entry_mutex );
}
+/* These parameters work well on AMD64 */
+#if 0
+#define STRIDE 8
+#define STRIPE 5
+#else
+#define STRIDE 1
+#define STRIPE 1
+#endif
+#define STRIDE_FACTOR (STRIDE*STRIPE)
+
int
entry_prealloc( int num )
{
- Entry *e;
+ Entry *e, **prev, *tmp;
slap_list *s;
+ int i, j;
if (!num) return 0;
+#if STRIDE_FACTOR > 1
+ /* Round up to our stride factor */
+ num += STRIDE_FACTOR-1;
+ num /= STRIDE_FACTOR;
+ num *= STRIDE_FACTOR;
+#endif
+
s = ch_calloc( 1, sizeof(slap_list) + num * sizeof(Entry));
s->next = entry_chunks;
entry_chunks = s;
- e = (Entry *)(s+1);
- for ( ;num>1; num--) {
- e->e_private = e+1;
- e++;
+ prev = &tmp;
+ for (i=0; i<STRIPE; i++) {
+ e = (Entry *)(s+1);
+ e += i;
+ for (j=i; j<num; j+= STRIDE) {
+ *prev = e;
+ prev = (Entry **)&e->e_private;
+ e += STRIDE;
+ }
}
- e->e_private = entry_list;
+ *prev = entry_list;
entry_list = (Entry *)(s+1);
return 0;