X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/c04af6970114f2209fce571d35ad2b1511119dc8..a02348b5df636914e356b539d91ed21f7b3a1ab5:/lib/pool_alloc.c diff --git a/lib/pool_alloc.c b/lib/pool_alloc.c index 05b182c2..0fb31225 100644 --- a/lib/pool_alloc.c +++ b/lib/pool_alloc.c @@ -52,7 +52,7 @@ pool_create(size_t size, size_t quantum, void (*bomb)(const char *), int flags) pool->size = size /* round extent size to min alignment reqs */ ? (size + MINALIGN - 1) & ~(MINALIGN - 1) : POOL_DEF_EXTENT; - if (pool->flags & POOL_INTERN) { + if (flags & POOL_INTERN) { pool->size -= sizeof (struct pool_extent); flags |= POOL_APPEND; } @@ -226,15 +226,9 @@ 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) + if (!pool || !addr) 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)) @@ -261,6 +255,7 @@ pool_free_old(alloc_pool_t p, void *addr) cur->free -= skew; } next = cur->next; + cur->next = NULL; } } else { next = cur->next;