2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
6 #include "iffparse_intern.h"
8 /*****************************************************************************
11 #include <proto/iffparse.h>
13 AROS_LH4(struct LocalContextItem
*, AllocLocalItem
,
16 AROS_LHA(LONG
, type
, D0
),
17 AROS_LHA(LONG
, id
, D1
),
18 AROS_LHA(LONG
, ident
, D2
),
19 AROS_LHA(ULONG
, dataSize
, D3
),
22 struct Library
*, IFFParseBase
, 31, IFFParse
)
25 Allocates and initializes a LocalContextItem structure. It also allocates
26 dataSize user data. User data can be accesseed via LocalItemData function.
27 This is the only way to allocate such a item, since the item contains private
28 fields. Of course programmers should assume NOTHING about this private
33 type, id - Longword identifications values.
34 ident - Longword identifier for class of item.
35 dataSize - Size of a user data area that will be allocated by this funcyion.
38 item - A initialized LocalContextItem structure.
41 Changed dataSize parameter to ULONG, negative-sized memory allocations are undefined.
50 FreeLocalItem(), LocalItemData(), StoreLocalItem(), StoreItemInContext(),
55 *****************************************************************************/
59 struct IntLocalContextItem
*intlci
;
61 DEBUG_ALLOCLOCALITEM(dprintf("AllocLocalItem: type 0x%lx %c%c%c%c id 0x%lx %c%c%c%c ident 0x%lx %c%c%c&%c\n",
62 type
, dmkid(type
), id
, dmkid(id
), ident
, dmkid(ident
)));
64 if (!(intlci
= AllocMem(sizeof (struct IntLocalContextItem
), MEMF_ANY
|MEMF_CLEAR
)))
66 DEBUG_ALLOCLOCALITEM(dprintf("AllocLocalItem: out of memory #1!\n"));
70 GetLCI(intlci
)->lci_ID
= id
;
71 GetLCI(intlci
)->lci_Type
= type
;
72 GetLCI(intlci
)->lci_Ident
= ident
;
74 /* Only allocate user date if dataSize > 0 */
77 if (!(intlci
->lci_UserData
= AllocMem(dataSize
, MEMF_ANY
|MEMF_CLEAR
)))
79 FreeMem(intlci
,sizeof (struct IntLocalContextItem
));
80 DEBUG_ALLOCLOCALITEM(dprintf("AllocLocalItem: out of memory #2!\n"));
84 /* Remember to set UserDataSize field for use in FreeLocalItem */
85 intlci
->lci_UserDataSize
= dataSize
;
89 /* If no dataSize, then we set then we do not have userdata */
90 intlci
->lci_UserData
= NULL
;
94 DEBUG_ALLOCLOCALITEM(dprintf("AllocLocalItem: return %p\n", intlci
));
95 return ((struct LocalContextItem
*)intlci
);
99 } /* AllocLocalItem */