Only clear portion of framebuffer that's actually used (clearing 256MB
[cake.git] / compiler / alib / libfreepooled.c
blob4aa5c0c725a39b8856971b4bad69a62e0a16bfe0
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Original version from libnix
4 $Id$
5 */
7 #include "pool.h"
8 #include <proto/exec.h>
10 /*****************************************************************************
12 NAME */
13 #include <proto/alib.h>
15 void LibFreePooled (
17 /* SYNOPSIS */
18 APTR pool,
19 APTR memory,
20 ULONG memSize)
22 /* FUNCTION
24 INPUTS
26 RESULT
28 NOTES
30 EXAMPLE
32 BUGS
34 SEE ALSO
36 INTERNALS
38 HISTORY
39 06.12.96 digulla Created after original from libnix
41 ******************************************************************************/
43 # define poolHeader ((POOL *)pool)
44 if (SysBase->LibNode.lib_Version >= 39)
46 FreePooled (poolHeader, memory, memSize);
47 return;
50 if (poolHeader!=NULL && memory!=NULL)
52 ULONG size,
53 * puddle = (ULONG *)((struct MinNode *)memory - 1) - 1;
55 if (poolHeader->ThreshSize>memSize)
57 struct MemHeader * a = (struct MemHeader *)&poolHeader->PuddleList.mlh_Head;
59 for(;;)
61 a = (struct MemHeader *)a->mh_Node.ln_Succ;
63 if (a->mh_Node.ln_Succ == NULL)
64 return;
66 if (a->mh_Node.ln_Type && memory >= a->mh_Lower
67 && memory < a->mh_Upper
69 break;
72 Deallocate (a, memory, memSize);
74 if (a->mh_Free != poolHeader->PuddleSize)
75 return;
77 puddle = (ULONG *)&a->mh_Node;
80 Remove ((struct Node *)puddle);
82 size = *--puddle;
83 FreeMem (puddle, size);
85 } /* LibFreePooled */