From a284efdd377afc901c697be08d1f3bc3c99abede Mon Sep 17 00:00:00 2001 From: schulz Date: Sun, 19 May 2013 13:21:10 +0000 Subject: [PATCH] handle MEMF_MANAGED DeletePool() call. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@47428 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/exec/deletepool.c | 81 +++++++++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/rom/exec/deletepool.c b/rom/exec/deletepool.c index 1bc61c5085..abb5fd06cf 100644 --- a/rom/exec/deletepool.c +++ b/rom/exec/deletepool.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. + Copyright � 1995-2011, The AROS Development Team. All rights reserved. $Id$ Desc: Delete a memory pool including all its memory. @@ -8,6 +8,7 @@ #include #include +#include #include #include "exec_intern.h" @@ -57,40 +58,50 @@ /* It is legal to DeletePool(NULL) */ if (poolHeader != NULL) { - struct TraceLocation tp = CURRENT_LOCATION("DeletePool"); - struct Pool *pool = poolHeader + MEMHEADER_TOTAL; - struct Node *p, *p2; /* Avoid casts */ - - D(bug("[DeletePool] Pool header 0x%p\n", pool)); - - /* - * We are going to deallocate the whole pool. - * Scan mungwall's allocations list and remove all chunks belonging to the pool. - */ - MungWall_Scan(pool, &tp, SysBase); - - /* - * Free the list of puddles. - * Remember that initial puddle containing the pool structure is also in this list. - * We do not need to free it until everything else is freed. - */ - for (p = (struct Node *)pool->PuddleList.mlh_Head; p->ln_Succ; p = p2) - { - p2 = p->ln_Succ; - - D(bug("[DeletePool] Puddle 0x%p...", p)); - - if (p != poolHeader) - { - D(bug(" freeing")); - FreeMemHeader(p, &tp, SysBase); - } - D(bug("\n")); - } - - /* Free the last puddle, containing the pool header */ - D(bug("[DeletePool] Freeing initial puddle 0x%p\n", poolHeader)); - FreeMemHeader(poolHeader, &tp, SysBase); + struct TraceLocation tp = CURRENT_LOCATION("DeletePool"); + struct Pool *pool = poolHeader + MEMHEADER_TOTAL; + struct Node *p, *p2; /* Avoid casts */ + struct MemHeaderExt *mhe = (struct MemHeaderExt *)poolHeader; + + D(bug("[DeletePool] Pool header 0x%p\n", pool)); + + /* + * The poolHeader is in fact a MemHeader structure. Check, if it was + * MEMF_MANAGED memory... + */ + if (!(mhe->mhe_MemHeader.mh_Attributes & MEMF_MANAGED)) + { + /* + * We are going to deallocate the whole pool. + * Scan mungwall's allocations list and remove all chunks belonging to the pool. + */ + MungWall_Scan(pool, &tp, SysBase); + + /* + * Free the list of puddles. + * Remember that initial puddle containing the pool structure is also in this list. + * We do not need to free it until everything else is freed. + */ + for (p = (struct Node *)pool->PuddleList.mlh_Head; p->ln_Succ; p = p2) + { + p2 = p->ln_Succ; + + D(bug("[DeletePool] Puddle 0x%p...", p)); + + if (p != poolHeader) + { + D(bug(" freeing")); + FreeMemHeader(p, &tp, SysBase); + } + D(bug("\n")); + } + + + } + + /* Free the last puddle, containing the pool header */ + D(bug("[DeletePool] Freeing initial puddle 0x%p\n", poolHeader)); + FreeMemHeader(poolHeader, &tp, SysBase); } AROS_LIBFUNC_EXIT -- 2.11.4.GIT