+int
+entry_prealloc( int num )
+{
+ Entry *e;
+ slap_list *s;
+
+ if (!num) return 0;
+
+ 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++;
+ }
+ e->e_private = entry_list;
+ entry_list = (Entry *)(s+1);
+
+ return 0;
+}
+
+Entry *
+entry_alloc( void )
+{
+ Entry *e;
+
+ ldap_pvt_thread_mutex_lock( &entry_mutex );
+ if ( !entry_list )
+ entry_prealloc( CHUNK_SIZE );
+ e = entry_list;
+ entry_list = e->e_private;
+ e->e_private = NULL;
+ ldap_pvt_thread_mutex_unlock( &entry_mutex );
+
+ return e;
+}
+
+