From 5269a7d1e2fba4e7e076c86f9f35bb2dbb3b62c4 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Sat, 5 Jan 2002 00:03:05 +0000 Subject: Prune free'd nodes from our free list otherwise we'll end up re-using 2002-01-04 Jeffrey Stedfast * e-memory.c (e_memchunk_clean): Prune free'd nodes from our free list otherwise we'll end up re-using free'd memory blocks and that's not a Good Thing (tm). svn path=/trunk/; revision=15250 --- e-util/ChangeLog | 6 ++++++ e-util/e-memory.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'e-util') diff --git a/e-util/ChangeLog b/e-util/ChangeLog index f66cd9af06..5de15f534f 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,9 @@ +2002-01-04 Jeffrey Stedfast + + * e-memory.c (e_memchunk_clean): Prune free'd nodes from our free + list otherwise we'll end up re-using free'd memory blocks and + that's not a Good Thing (tm). + 2002-01-02 Jeffrey Stedfast * md5-utils.h: Reverted. diff --git a/e-util/e-memory.c b/e-util/e-memory.c index 0dc865225d..108a627076 100644 --- a/e-util/e-memory.c +++ b/e-util/e-memory.c @@ -307,6 +307,23 @@ e_memchunk_clean(MemChunk *m) ci = hi; while (ci) { if (ci->count == m->blocksize) { + MemChunkFreeNode *prev = NULL; + + f = m->free; + while (f) { + if (tree_search (ci, (void *) f) == 0) { + /* prune this node from our free-node list */ + if (prev) + prev->next = f->next; + else + m->free = f->next; + } else { + prev = f; + } + + f = f->next; + } + g_ptr_array_remove_fast(m->blocks, ci->base); g_free(ci->base); } -- cgit v1.2.3