]> git.sur5r.net Git - openldap/commitdiff
ITS#6437 cleanup (noop change): Simplify slap_sl_free() code reclaiming space
authorHallvard Furuseth <hallvard@openldap.org>
Sat, 2 Jan 2010 18:42:33 +0000 (18:42 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Sat, 2 Jan 2010 18:42:33 +0000 (18:42 +0000)
servers/slapd/sl_malloc.c

index 5acdab88e2abd54a4e1e1cfa64a22b13c0ac3962..2309f13946a538a442c7cb83d6af6fc96464f737 100644 (file)
@@ -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;