2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Original version from libnix
7 #define AROS_LIBREQ(base,ver) /* We test for versions manually */
10 #include <proto/exec.h>
12 /*****************************************************************************
15 #include <proto/alib.h>
40 06.12.96 digulla Created after original from libnix
42 ******************************************************************************/
44 # define poolHeader ((POOL *)pool)
47 if (SysBase
->LibNode
.lib_Version
>= 39)
48 return (AllocPooled (pool
, memSize
));
50 if (poolHeader
!= NULL
&& memSize
!= 0)
54 if (poolHeader
->ThreshSize
> memSize
)
56 struct MemHeader
* a
= (struct MemHeader
*)poolHeader
->PuddleList
.mlh_Head
;
60 if (a
->mh_Node
.ln_Succ
!=NULL
)
62 if (a
->mh_Node
.ln_Type
63 && (puddle
= (ULONG
*)Allocate (a
, memSize
)) != NULL
67 a
= (struct MemHeader
*)a
->mh_Node
.ln_Succ
;
71 size
= poolHeader
->PuddleSize
72 + sizeof (struct MemHeader
)
75 if (!(puddle
= (ULONG
*)AllocMem (size
, poolHeader
->MemoryFlags
)) )
80 a
= (struct MemHeader
*)puddle
;
82 a
->mh_Node
.ln_Type
= NT_MEMORY
;
84 a
->mh_First
= (struct MemChunk
*)(
86 + sizeof (struct MemHeader
)
89 a
->mh_First
->mc_Next
= NULL
;
91 a
->mh_First
->mc_Bytes
= poolHeader
->PuddleSize
;
92 a
->mh_Upper
= (char *)a
->mh_First
+ a
->mh_Free
;
94 AddHead ((struct List
*)&poolHeader
->PuddleList
, &a
->mh_Node
);
96 puddle
= (ULONG
*)Allocate (a
, memSize
);
103 We do have to clear memory here. It may have been dirtied
104 by somebody using it beforehand.
106 if (poolHeader
->MemoryFlags
& MEMF_CLEAR
)
122 size
= memSize
+ sizeof (struct MinNode
) + 2 * sizeof (ULONG
);
124 if ((puddle
= (ULONG
*)AllocMem (size
, poolHeader
->MemoryFlags
)))
128 AddTail ((struct List
*)&poolHeader
->PuddleList
129 , (struct Node
*)puddle
132 puddle
= (ULONG
*)((struct MinNode
*)puddle
+ 1);
140 } /* LibAllocPooled */