Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / network / stacks / AROSTCP / MUI.MiamiPanel / muimiamipanel_message.c
blob062ce92e8771015340d52992d0fd1964d4a91b1d
2 #include <proto/exec.h>
4 #include "muimiamipanel_intern.h"
5 #include "muimiamipanel_message.h"
7 /****************************************************************************/
9 struct MPS_Msg *
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;
18 mstate = succ);
20 if (succ)
22 Remove((struct Node *)mstate);
23 MiamiPanelBaseIntern->mpb_freeMsg--;
25 else
27 if (size<STDSIZE) size = STDSIZE;
29 if (mstate = AllocPooled(MiamiPanelBaseIntern->mpb_pool,size))
30 mstate->size = size;
33 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_memSem);
35 return mstate;
38 /****************************************************************************/
40 void
41 freeMsg(struct MPS_Msg *msg, struct MiamiPanelBase_intern *MiamiPanelBaseIntern)
43 ObtainSemaphore(&MiamiPanelBaseIntern->mpb_memSem);
45 if (MiamiPanelBaseIntern->mpb_freeMsg<MAXFREENUM)
47 register ULONG size;
49 memset(msg,0,size = msg->size);
50 AddHead((struct List *)&MiamiPanelBaseIntern->mpb_msgList,(struct Node *)msg);
51 msg->size = size;
52 MiamiPanelBaseIntern->mpb_freeMsg++;
54 else FreePooled(MiamiPanelBaseIntern->mpb_pool,msg,msg->size);
56 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_memSem);
59 /****************************************************************************/