home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / memory / src / allocvec.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  1.6 KB  |  80 lines

  1. /*
  2.     (C) 1995 AROS - The Amiga Replacement OS
  3.     $Id: allocvec.c 1.1 1995/11/14 22:31:07 digulla Exp digulla $
  4.     $Log: allocvec.c $
  5.  * Revision 1.1  1995/11/14  22:31:07  digulla
  6.  * Initial revision
  7.  *
  8.     Desc:
  9.     Lang: english
  10. */
  11. #include "exec_intern.h"
  12. #include "memory.h"
  13.  
  14. /*****************************************************************************
  15.  
  16.     NAME */
  17.     #include <clib/exec_protos.h>
  18.  
  19.     __AROS_LH2(APTR, AllocVec,
  20.  
  21. /*  SYNOPSIS */
  22.     __AROS_LA(unsigned long, byteSize, D0),
  23.     __AROS_LA(unsigned long, requirements, D1),
  24.  
  25. /*  LOCATION */
  26.     struct ExecBase *, SysBase, 114, Exec)
  27.  
  28. /*  FUNCTION
  29.     Allocate some memory from the sytem memory pool with the given
  30.     requirements and without the need to memorize the actual size
  31.     of the block.
  32.  
  33.     INPUTS
  34.     byteSize     - Number of bytes you want to get
  35.     requirements - Type of memory
  36.  
  37.     RESULT
  38.     A pointer to the number of bytes you wanted or NULL if the memory
  39.     couldn't be allocated
  40.  
  41.     NOTES
  42.  
  43.     EXAMPLE
  44.  
  45.     BUGS
  46.  
  47.     SEE ALSO
  48.     FreeVec()
  49.  
  50.     INTERNALS
  51.  
  52.     HISTORY
  53.     08-10-95    created by m. fleischer
  54.     16-10-95    increased portability
  55.     26-10-95    digulla adjusted to new calling scheme
  56.  
  57. ******************************************************************************/
  58. {
  59.     __AROS_FUNC_INIT
  60.     UBYTE *ret;
  61.  
  62.     /* Add room for stored size. */
  63.     byteSize+=ALLOCVEC_TOTAL;
  64.  
  65.     /* Get the memory. */
  66.     ret=(UBYTE *)AllocMem(byteSize,requirements);
  67.  
  68.     /* If there's not enough memory left return immediately. */
  69.     if(ret==NULL)
  70.     return NULL;
  71.  
  72.     /* Store size */
  73.     *(ULONG *)ret=byteSize;
  74.  
  75.     /* return free space */
  76.     return ret+ALLOCVEC_TOTAL;
  77.     __AROS_FUNC_EXIT
  78. } /* AllocVec */
  79.  
  80.