Allow a NULL address to be passed to pool_free_old() to indicate that
authorWayne Davison <wayned@samba.org>
Wed, 6 Jun 2007 15:38:31 +0000 (15:38 +0000)
committerWayne Davison <wayned@samba.org>
Wed, 6 Jun 2007 15:38:31 +0000 (15:38 +0000)
it should free all old mem and reset to an empty state.

lib/pool_alloc.c

index 7d95f19..05b182c 100644 (file)
@@ -226,9 +226,15 @@ pool_free_old(alloc_pool_t p, void *addr)
        struct alloc_pool *pool = (struct alloc_pool *)p;
        struct pool_extent *cur, *prev, *next;
 
-       if (!pool || !addr)
+       if (!pool)
                return;
 
+       if (!addr) {
+               if (!pool->extents)
+                       return;
+               addr = PTR_ADD(pool->extents->start, pool->extents->free);
+       }
+
        for (prev = NULL, cur = pool->extents; cur; prev = cur, cur = cur->next) {
                if (addr >= cur->start
                    && addr < PTR_ADD(cur->start, pool->size))