2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
8 #include "icon_intern.h"
10 /*****************************************************************************
13 #include <proto/icon.h>
15 AROS_LH3(BOOL
, AddFreeList
,
18 AROS_LHA(struct FreeList
*, freelist
, A0
),
19 AROS_LHA(APTR
, mem
, A1
),
20 AROS_LHA(unsigned long , size
, A2
),
23 struct Library
*, IconBase
, 12, Icon
)
26 Adds supplied memory chunk to the supplied freelist.
27 All memory added in to the freelist can later be deallocated through
28 one single FreeFreeList() call.
31 freelist - pointer to freelist struct previously allocated by
33 mem - memory to add to the freelist.
34 size - size of memory chunk to add to the frelist.
37 FALSE on failure, else TRUE.
52 *****************************************************************************/
56 struct MemList
*memlist
;
57 struct MemEntry
*mementry
;
59 /* We get hold of the last memlist node inside the list */
60 memlist
= (struct MemList
*)freelist
->fl_MemList
.lh_TailPred
;
62 /* Is this memlist full ? */
63 if (memlist
->ml_NumEntries
== FREELIST_MEMLISTENTRIES
64 || freelist
->fl_NumFree
== 0
67 /* No more room, we must allocate a new entry */
68 if (!(memlist
= AllocMem (sizeof(struct IconInternalMemList
),
73 memlist
->ml_NumEntries
= 0;
75 AddTail ((struct List
*)&freelist
->fl_MemList
, (struct Node
*)memlist
);
78 /* Insert the the supplied parameters */
79 mementry
= &memlist
->ml_ME
[ memlist
->ml_NumEntries
];
81 mementry
->me_Un
.meu_Addr
= mem
;
82 mementry
->me_Length
= size
;
84 memlist
->ml_NumEntries
++;
86 freelist
->fl_NumFree
++;