home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / workbench / libs / iffparse / alloclocalitem.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-03  |  2.5 KB  |  115 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: alloclocalitem.c,v 1.1 1997/02/03 16:44:21 digulla Exp $
  4.  
  5.     Desc:
  6.     Lang: english
  7. */
  8. #include "iffparse_intern.h"
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13. #include <proto/iffparse.h>
  14.  
  15.     AROS_LH4(struct LocalContextItem *, AllocLocalItem,
  16.  
  17. /*  SYNOPSIS */
  18.     AROS_LHA(LONG, type, D0),
  19.     AROS_LHA(LONG, id, D1),
  20.     AROS_LHA(LONG, ident, D2),
  21.     AROS_LHA(ULONG, dataSize, D3),
  22.  
  23. /*  LOCATION */
  24.     struct Library *, IFFParseBase, 31, IFFParse)
  25.  
  26. /*  FUNCTION
  27.     Allocates and initializes a LocalContextItem structure. It also allocates
  28.     dataSize user data. User data can be accesseed via LocalItemData function.
  29.     This is the only way to allocate such a item, since the item contains private
  30.     fields. Of course programmers should assume NOTHING about this private
  31.     fields.
  32.  
  33.  
  34.     INPUTS
  35.     type, id   - Longword identifications values.
  36.     ident       - Longword identifier for class of item.
  37.     dataSize      -  Size of a user data area that will be allocated by this funcyion.
  38.  
  39.     RESULT
  40.     item      - A initialized LocalContextItem structure.
  41.  
  42.     NOTES
  43.     Changed dataSize parameter to ULONG, negative-sized memory allocations are undefined.
  44.  
  45.  
  46.     EXAMPLE
  47.  
  48.     BUGS
  49.     See notes.
  50.  
  51.     SEE ALSO
  52.     FreeLocalItem(), LocalItemData(), StoreLocalItem(), StoreItemInContext(),
  53.     SetLocalItemPurge()
  54.  
  55.     INTERNALS
  56.  
  57.     HISTORY
  58.   27-11-96    digulla automatically created from
  59.       iffparse_lib.fd and clib/iffparse_protos.h
  60.  
  61. *****************************************************************************/
  62. {
  63.     AROS_LIBFUNC_INIT
  64.     AROS_LIBBASE_EXT_DECL(struct Library *,IFFParseBase)
  65.  
  66.     struct IntLocalContextItem *intlci;
  67.  
  68.     if
  69.     (
  70.     !(intlci = AllocMem
  71.         (
  72.         sizeof (struct IntLocalContextItem),
  73.         MEMF_ANY|MEMF_CLEAR
  74.         )
  75.     )
  76.     )
  77.     return (FALSE);
  78.  
  79.     GetLCI(intlci)->lci_ID     = id;
  80.     GetLCI(intlci)->lci_Type   = type;
  81.     GetLCI(intlci)->lci_Ident  = ident;
  82.  
  83.     /* Only allocate user date if dataSize > 0 */
  84.     if (dataSize > 0)
  85.     {
  86.     if
  87.     (
  88.         !(intlci->lci_UserData = AllocMem
  89.         (
  90.             dataSize,
  91.             MEMF_ANY|MEMF_CLEAR
  92.         )
  93.         )
  94.     )
  95.     {
  96.         FreeMem(intlci,sizeof (struct IntLocalContextItem));
  97.         return (FALSE);
  98.     }
  99.  
  100.     /* Remember to set UserDataSize field for use in FreeLocalItem */
  101.     intlci->lci_UserDataSize = dataSize;
  102.     }
  103.     else
  104.     {
  105.     /* If no dataSize, then we set then we do not have userdata */
  106.     intlci->lci_UserData = NULL;
  107.     }
  108.  
  109.  
  110.     return ((struct LocalContextItem*)intlci);
  111.  
  112.  
  113.     AROS_LIBFUNC_EXIT
  114. } /* AllocLocalItem */
  115.