From: Howard Chu Date: Tue, 14 Mar 2017 08:50:17 +0000 (+0000) Subject: ITS#8725 add slap_sl_mark / slap_sl_release X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=db3909d27d78bbe62de25fa8136428e27d4a7e4e;p=openldap ITS#8725 add slap_sl_mark / slap_sl_release For fast cleanup after constructing disposable entries --- diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 7478067ea4..84013edd31 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1858,6 +1858,11 @@ LDAP_SLAPD_F (void *) slap_sl_calloc LDAP_P(( ber_len_t nelem, ber_len_t size, void *ctx )); LDAP_SLAPD_F (void) slap_sl_free LDAP_P(( void *, void *ctx )); +LDAP_SLAPD_F (void) slap_sl_release LDAP_P(( + void *, void *ctx )); +LDAP_SLAPD_F (void *) slap_sl_mark LDAP_P(( + void *ctx )); + LDAP_SLAPD_V (BerMemoryFunctions) slap_sl_mfuncs; diff --git a/servers/slapd/sl_malloc.c b/servers/slapd/sl_malloc.c index ff56c4f249..32b61f40e4 100644 --- a/servers/slapd/sl_malloc.c +++ b/servers/slapd/sl_malloc.c @@ -137,6 +137,9 @@ slap_sl_mem_destroy( struct slab_object *so; int i; + if (!sh) + return; + if (!sh->sh_stack) { for (i = 0; i <= sh->sh_maxorder - order_start; i++) { so = LDAP_LIST_FIRST(&sh->sh_free[i]); @@ -649,6 +652,21 @@ slap_sl_free(void *ptr, void *ctx) } } +void +slap_sl_release( void *ptr, void *ctx ) +{ + struct slab_heap *sh = ctx; + if ( sh && ptr >= sh->sh_base && ptr <= sh->sh_end ) + sh->sh_last = ptr; +} + +void * +slap_sl_mark( void *ctx ) +{ + struct slab_heap *sh = ctx; + return sh->sh_last; +} + /* * Return the memory context of the current thread if the given block of * memory belongs to it, otherwise return NULL.