ber_tag_t oldtag = tag;
#endif /* SLAPD_MONITOR */
Connection *conn = op->o_conn;
+ void *memctx;
ldap_pvt_thread_mutex_lock( &num_ops_mutex );
num_ops_initiated++;
*/
#define SLAB_SIZE 1048576
if ( tag == LDAP_REQ_SEARCH ) {
- sl_mem_create( SLAB_SIZE, ctx );
- ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, ctx );
- op->o_tmpmemctx = ctx;
+ memctx = sl_mem_create( SLAB_SIZE, ctx );
+ ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, memctx );
+ op->o_tmpmemctx = memctx;
op->o_tmpalloc = sl_malloc;
op->o_tmpfree = sl_free;
} else {
ber_set_option( NULL, LBER_OPT_MEMORY_FNS, &sl_bmf );
}
-void
+void *
sl_mem_create(
ber_len_t size,
void *ctx
}
sh->h_last = sh->h_base;
sh->h_end = sh->h_base + size;
+ return sh;
}
void *
void *ctx
)
{
- struct slab_heap *sh = NULL;
+ struct slab_heap *sh = ctx;
int pad = 2*sizeof(int)-1;
ber_len_t *new;
/* ber_set_option calls us like this */
if (!ctx) return ber_memalloc_x( size, NULL );
- ldap_pvt_thread_pool_getkey( ctx, sl_mem_init, (void **)&sh, NULL );
-
/* round up to doubleword boundary */
size += pad + sizeof( ber_len_t );
size &= ~pad;
void *
sl_realloc( void *ptr, ber_len_t size, void *ctx )
{
- struct slab_heap *sh = NULL;
+ struct slab_heap *sh = ctx;
int pad = 2*sizeof(int)-1;
ber_len_t *p = (ber_len_t *)ptr;
ber_len_t *new;
- ldap_pvt_thread_pool_getkey( ctx, sl_mem_init, (void **)&sh, NULL );
-
if ( ptr == NULL ) return sl_malloc( size, ctx );
if ( ptr < sh->h_base || ptr >= sh->h_end ) {
void
sl_free( void *ptr, void *ctx )
{
- struct slab_heap *sh = NULL;
-
- ldap_pvt_thread_pool_getkey( ctx, sl_mem_init, (void **)&sh, NULL );
+ struct slab_heap *sh = ctx;
if ( ptr < sh->h_base || ptr >= sh->h_end ) {
#ifdef NEW_LOGGING