New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / compiler / alib / libfreepooled.c
blobc23fc623dcc9e4cfd62d55ea3e6be73a5f749dd2
1 /*
2 Copyright © 1995-2001, 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 AROS_GET_SYSBASE_OK
46 if (SysBase->LibNode.lib_Version >= 39)
48 FreePooled (poolHeader, memory, memSize);
49 return;
52 if (poolHeader!=NULL && memory!=NULL)
54 ULONG size,
55 * puddle = (ULONG *)((struct MinNode *)memory - 1) - 1;
57 if (poolHeader->ThreshSize>memSize)
59 struct MemHeader * a = (struct MemHeader *)&poolHeader->PuddleList.mlh_Head;
61 for(;;)
63 a = (struct MemHeader *)a->mh_Node.ln_Succ;
65 if (a->mh_Node.ln_Succ == NULL)
66 return;
68 if (a->mh_Node.ln_Type && memory >= a->mh_Lower
69 && memory < a->mh_Upper
71 break;
74 Deallocate (a, memory, memSize);
76 if (a->mh_Free != poolHeader->PuddleSize)
77 return;
79 puddle = (ULONG *)&a->mh_Node;
82 Remove ((struct Node *)puddle);
84 size = *--puddle;
85 FreeMem (puddle, size);
87 } /* LibFreePooled */