2 Copyright © 1995-2013, 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 IconBase
*, IconBase
, 12, Icon
)
26 Adds supplied memory chunk to the supplied freelist. The memory chunk
27 must have been allocated by AllocMem(). All memory added into the
28 freelist can later be deallocated through a 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 freelist.
37 FALSE on failure, else TRUE.
52 *****************************************************************************/
56 struct MemList
*memlist
;
57 struct MemEntry
*mementry
;
58 /* We get hold of the last memlist node inside the list */
59 memlist
= (struct MemList
*)freelist
->fl_MemList
.lh_TailPred
;
61 /* Is this memlist full? */
62 if (freelist
->fl_NumFree
== 0)
64 /* No more room, we must allocate a new entry */
65 if (!(memlist
= AllocMem (sizeof(struct IconInternalMemList
),
70 freelist
->fl_NumFree
= FREELIST_MEMLISTENTRIES
;
71 memlist
->ml_NumEntries
= FREELIST_MEMLISTENTRIES
;
73 AddTail ((struct List
*)&freelist
->fl_MemList
, (struct Node
*)memlist
);
76 /* Insert the supplied parameters */
77 mementry
= &memlist
->ml_ME
[freelist
->fl_NumFree
- 1];
79 mementry
->me_Un
.meu_Addr
= mem
;
80 mementry
->me_Length
= size
;
82 freelist
->fl_NumFree
--;