2 #include <proto/exec.h>
4 #include "muimiamipanel_intern.h"
5 #include "muimiamipanel_message.h"
7 /****************************************************************************/
10 createMsg(ULONG size
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
12 register struct MPS_Msg
*mstate
, *succ
;
14 ObtainSemaphore(&MiamiPanelBaseIntern
->mpb_memSem
);
16 for (mstate
= (struct MPS_Msg
*)MiamiPanelBaseIntern
->mpb_msgList
.mlh_Head
;
17 (succ
= (struct MPS_Msg
*)mstate
->link
.mn_Node
.ln_Succ
) && mstate
->size
<size
;
22 Remove((struct Node
*)mstate
);
23 MiamiPanelBaseIntern
->mpb_freeMsg
--;
27 if (size
<STDSIZE
) size
= STDSIZE
;
29 if (mstate
= AllocPooled(MiamiPanelBaseIntern
->mpb_pool
,size
))
33 ReleaseSemaphore(&MiamiPanelBaseIntern
->mpb_memSem
);
38 /****************************************************************************/
41 freeMsg(struct MPS_Msg
*msg
, struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
)
43 ObtainSemaphore(&MiamiPanelBaseIntern
->mpb_memSem
);
45 if (MiamiPanelBaseIntern
->mpb_freeMsg
<MAXFREENUM
)
49 memset(msg
,0,size
= msg
->size
);
50 AddHead((struct List
*)&MiamiPanelBaseIntern
->mpb_msgList
,(struct Node
*)msg
);
52 MiamiPanelBaseIntern
->mpb_freeMsg
++;
54 else FreePooled(MiamiPanelBaseIntern
->mpb_pool
,msg
,msg
->size
);
56 ReleaseSemaphore(&MiamiPanelBaseIntern
->mpb_memSem
);
59 /****************************************************************************/