branch: support configuring --sort via .gitconfig
[gitweb.git] / mem-pool.c
index b250a5fe40bb44eccdf053f49f8fd40a1ce10980..a2841a4a9ad7e4871282031f1b18fd62f18e9638 100644 (file)
@@ -50,14 +50,19 @@ void mem_pool_init(struct mem_pool **mem_pool, size_t initial_size)
        *mem_pool = pool;
 }
 
-void mem_pool_discard(struct mem_pool *mem_pool)
+void mem_pool_discard(struct mem_pool *mem_pool, int invalidate_memory)
 {
        struct mp_block *block, *block_to_free;
 
-       while ((block = mem_pool->mp_block))
+       block = mem_pool->mp_block;
+       while (block)
        {
                block_to_free = block;
                block = block->next_block;
+
+               if (invalidate_memory)
+                       memset(block_to_free->space, 0xDD, ((char *)block_to_free->end) - ((char *)block_to_free->space));
+
                free(block_to_free);
        }