delint for clang
[AROS.git] / compiler / alib / libfreepooled.c
blob1ecc8f7c66dc3a8a5044b595e6fb8829fe3b5f41
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Original version from libnix
4 $Id$
5 */
7 #define AROS_LIBREQ(base,ver) /* We test for versions manually */
9 #include "pool.h"
10 #include <proto/exec.h>
12 /*****************************************************************************
14 NAME */
15 #include <proto/alib.h>
17 void LibFreePooled (
19 /* SYNOPSIS */
20 APTR pool,
21 APTR memory,
22 ULONG memSize)
24 /* FUNCTION
26 INPUTS
28 RESULT
30 NOTES
32 EXAMPLE
34 BUGS
36 SEE ALSO
38 INTERNALS
40 HISTORY
41 06.12.96 digulla Created after original from libnix
43 ******************************************************************************/
45 # define poolHeader ((POOL *)pool)
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 */