Added memory-stored debug output to safe mode.
[cake.git] / workbench / libs / asl / allocaslrequest.c
blob4ad9384abf3e443e63975a6291ca88c866d9904b
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
10 #include <proto/exec.h>
11 #include <proto/dos.h>
12 #include <proto/utility.h>
13 #include <proto/locale.h>
14 #include <exec/memory.h>
15 #include <dos/dos.h>
16 #include "asl_intern.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/asl.h>
22 #include <libraries/asl.h>
23 #include <utility/tagitem.h>
26 AROS_LH2(APTR, AllocAslRequest,
28 /* SYNOPSIS */
29 AROS_LHA(ULONG , reqType, D0),
30 AROS_LHA(struct TagItem *, tagList, A0),
32 /* LOCATION */
33 struct Library *, AslBase, 8, Asl)
35 /* FUNCTION
37 INPUTS
39 RESULT
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 INTERNALS
51 HISTORY
52 27-11-96 digulla automatically created from
53 asl_lib.fd and clib/asl_protos.h
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
59 struct IntReq *intreq;
60 APTR req;
62 struct ReqNode *reqnode;
63 struct AslReqInfo *reqinfo;
65 SetIoErr(0);
67 /* Parameter check */
68 if
70 (reqType != ASL_FileRequest)
71 &&
72 (reqType != ASL_FontRequest)
74 (reqType != ASL_ScreenModeRequest)
76 return (NULL);
78 reqinfo = &(ASLB(AslBase)->ReqInfo[reqType]);
80 /* Allocate memory for internal requester structure */
81 intreq = AllocVec(reqinfo->IntReqSize, MEMF_ANY);
82 if (intreq)
84 req = AllocVec(reqinfo->ReqSize, MEMF_ANY|MEMF_CLEAR);
85 if (req)
87 CopyMem(reqinfo->DefaultReq, intreq, reqinfo->IntReqSize);
89 if (intreq->ir_MemPoolPuddle)
91 intreq->ir_MemPool = CreatePool(MEMF_PUBLIC | MEMF_CLEAR,
92 intreq->ir_MemPoolPuddle,
93 intreq->ir_MemPoolThresh);
96 if (!intreq->ir_MemPoolPuddle || intreq->ir_MemPool)
98 if (tagList) /* If no taglist is supplied, we use default values */
100 struct ParseTagArgs pta;
102 ParseCommonTags(intreq, tagList, ASLB(AslBase));
104 /* Parse tags specific for this type of requester */
105 pta.pta_IntReq = intreq;
106 pta.pta_Req = req;
107 pta.pta_Tags = tagList;
109 CallHookPkt(&(reqinfo->ParseTagsHook), &pta, ASLB(AslBase));
112 } /* if (tagList) */
114 /* Add requester to internal list */
115 reqnode = AllocMem(sizeof (struct ReqNode), MEMF_ANY);
116 if (reqnode)
118 reqnode->rn_Req = req;
119 reqnode->rn_IntReq = intreq;
120 reqnode->rn_ReqWindow = NULL;
121 ObtainSemaphore( &(ASLB(AslBase)->ReqListSem) );
122 AddTail( (struct List*)&(ASLB(AslBase)->ReqList), (struct Node*)reqnode);
123 ReleaseSemaphore(&(ASLB(AslBase)->ReqListSem));
125 SetIoErr(0);
127 return (req);
131 if (intreq->ir_MemPool) DeletePool(intreq->ir_MemPool);
133 } /* if no mempool needed or mempool creation ok */
134 FreeVec(req);
136 } /* if (Alloc public request structure) */
137 FreeVec(intreq);
139 } /* if (Alloc private request structure) */
141 SetIoErr(ERROR_NO_FREE_STORE);
143 return (NULL);
145 AROS_LIBFUNC_EXIT
146 } /* AllocAslRequest */