2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Delete a memory pool including all its memory.
9 #include <aros/libcall.h>
10 #include <exec/memory.h>
11 #include <proto/exec.h>
13 #include "exec_intern.h"
14 #include "exec_util.h"
18 /*****************************************************************************
22 AROS_LH1(void, DeletePool
,
25 AROS_LHA(APTR
, poolHeader
, A0
),
28 struct ExecBase
*, SysBase
, 117, Exec
)
31 Delete a pool including all it's memory.
34 poolHeader - The pool allocated with CreatePool() or NULL.
45 CreatePool(), AllocPooled(), FreePooled()
49 ******************************************************************************/
53 ASSERT_VALID_PTR_OR_NULL(poolHeader
);
55 D(bug("[exec] DeletePool(0x%p)\n", poolHeader
));
57 /* It is legal to DeletePool(NULL) */
58 if (poolHeader
!= NULL
)
60 struct TraceLocation tp
= CURRENT_LOCATION("DeletePool");
61 struct Pool
*pool
= poolHeader
+ MEMHEADER_TOTAL
;
62 struct Node
*p
, *p2
; /* Avoid casts */
64 D(bug("[DeletePool] Pool header 0x%p\n", pool
));
67 * We are going to deallocate the whole pool.
68 * Scan mungwall's allocations list and remove all chunks belonging to the pool.
70 MungWall_Scan(pool
, &tp
, SysBase
);
73 * Free the list of puddles.
74 * Remember that initial puddle containing the pool structure is also in this list.
75 * We do not need to free it until everything else is freed.
77 for (p
= (struct Node
*)pool
->PuddleList
.mlh_Head
; p
->ln_Succ
; p
= p2
)
81 D(bug("[DeletePool] Puddle 0x%p...", p
));
86 FreeMemHeader(p
, &tp
, SysBase
);
91 /* Free the last puddle, containing the pool header */
92 D(bug("[DeletePool] Freeing initial puddle 0x%p\n", poolHeader
));
93 FreeMemHeader(poolHeader
, &tp
, SysBase
);