From 4103a1052c160444c69bbfd246a7407b77a3307a Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Tue, 5 Jan 2010 19:40:28 +0000 Subject: [PATCH] ITS#6437 cleanup (noop patch): Join SLAP_NO_SL_MALLOC code with identical ctx==NULL code. Add enum No_sl_malloc to avoid #ifdef SLAP_NO_SL_MALLOC. --- servers/slapd/sl_malloc.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/servers/slapd/sl_malloc.c b/servers/slapd/sl_malloc.c index e4446addd3..71c4589dec 100644 --- a/servers/slapd/sl_malloc.c +++ b/servers/slapd/sl_malloc.c @@ -56,6 +56,12 @@ * freed, older blocks will not be reclaimed until the slab is reset... */ +#ifdef SLAP_NO_SL_MALLOC /* Useful with memory debuggers like Valgrind */ +enum { No_sl_malloc = 1 }; +#else +enum { No_sl_malloc = 0 }; +#endif + enum { Align = sizeof(ber_len_t) > 2*sizeof(int) ? sizeof(ber_len_t) : 2*sizeof(int), @@ -253,15 +259,8 @@ slap_sl_malloc( struct slab_heap *sh = ctx; ber_len_t *ptr, *newptr; -#ifdef SLAP_NO_SL_MALLOC - newptr = ber_memalloc_x( size, NULL ); - if ( newptr ) return newptr; - assert( 0 ); - exit( EXIT_FAILURE ); -#endif - /* ber_set_option calls us like this */ - if (!ctx) { + if (No_sl_malloc || !ctx) { newptr = ber_memalloc_x( size, NULL ); if ( newptr ) return newptr; Debug(LDAP_DEBUG_ANY, "slap_sl_malloc of %lu bytes failed\n", @@ -382,15 +381,8 @@ slap_sl_realloc(void *ptr, ber_len_t size, void *ctx) if (ptr == NULL) return slap_sl_malloc(size, ctx); -#ifdef SLAP_NO_SL_MALLOC - newptr = ber_memrealloc_x( ptr, size, NULL ); - if ( newptr ) return newptr; - assert( 0 ); - exit( EXIT_FAILURE ); -#endif - /* Not our memory? */ - if (!sh || ptr < sh->sh_base || ptr >= sh->sh_end) { + if (No_sl_malloc || !sh || ptr < sh->sh_base || ptr >= sh->sh_end) { /* Like ch_realloc(), except not trying a new context */ newptr = ber_memrealloc_x(ptr, size, NULL); if (newptr) { @@ -463,12 +455,7 @@ slap_sl_free(void *ptr, void *ctx) if (!ptr) return; -#ifdef SLAP_NO_SL_MALLOC - ber_memfree_x( ptr, NULL ); - return; -#endif - - if (!sh || ptr < sh->sh_base || ptr >= sh->sh_end) { + if (No_sl_malloc || !sh || ptr < sh->sh_base || ptr >= sh->sh_end) { ber_memfree_x(ptr, NULL); } else if (sh->sh_stack) { -- 2.39.5