From 4c36193a5c27853e5aec33b85607608d2ed17c3b Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Sat, 2 Jan 2010 18:42:33 +0000 Subject: [PATCH] ITS#6437 cleanup (noop change): Simplify slap_sl_free() code reclaiming space --- servers/slapd/sl_malloc.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/servers/slapd/sl_malloc.c b/servers/slapd/sl_malloc.c index 5acdab88e2..2309f13946 100644 --- a/servers/slapd/sl_malloc.c +++ b/servers/slapd/sl_malloc.c @@ -427,23 +427,21 @@ slap_sl_free(void *ptr, void *ctx) if (!sh || ptr < sh->sh_base || ptr >= sh->sh_end) { ber_memfree_x(ptr, NULL); + } else if (sh->sh_stack) { - tmpp = (ber_len_t *)((char *)ptr + p[-1]); + size = p[-1]; + p = (ber_len_t *) ((char *) ptr + size); /* mark it free */ - tmpp[-1] |= 1; + p[-1] = size |= 1; /* reclaim free space off tail */ - while ( tmpp == sh->sh_last ) { - if ( tmpp[-1] & 1 ) { - size = tmpp[-1] ^ 1; - ptr = (char *)tmpp - size; - p = (ber_len_t *)ptr; - p--; - sh->sh_last = p; - tmpp = sh->sh_last; - } else { - break; - } + if (sh->sh_last == p) { + do { + p = (ber_len_t *) ((char *) p - size + 1) - 1; + size = p[-1]; + } while (size & 1); + sh->sh_last = p; } + } else { int size_shift, order_size; struct slab_object *so; -- 2.39.5