home *** CD-ROM | disk | FTP | other *** search
/ ftptest.leeds.ac.uk / 2015.02.ftptest.leeds.ac.uk.tar / ftptest.leeds.ac.uk / bionet / CAE-GROUP / SCL-WIN3x / FED_PLUS.EXE / MEMORY.H < prev    next >
C/C++ Source or Header  |  1994-07-23  |  2KB  |  94 lines

  1. #ifndef MEMORY_H
  2. #define MEMORY_H
  3.  
  4. /* $Id: memory.h,v 1.4 1993/10/15 18:49:23 libes Exp $ */
  5.  
  6. /*
  7.  * This work was supported by the United States Government, and is
  8.  * not subject to copyright.
  9.  *
  10.  * $Log: memory.h,v $
  11.  * Revision 1.4  1993/10/15  18:49:23  libes
  12.  * CADDETC certified
  13.  *
  14.  * Revision 1.3  1993/02/22  21:41:13  libes
  15.  * ANSI compat
  16.  *
  17.  * Revision 1.2  1992/08/18  17:15:40  libes
  18.  * rm'd extraneous error messages
  19.  *
  20.  * Revision 1.1  1992/05/28  03:56:02  libes
  21.  * Initial revision
  22.  */
  23.  
  24. #include "basic.h"
  25. #include <malloc.h>
  26. #include <stdlib.h>
  27. /*****************/
  28. /* packages used */
  29. /*****************/
  30.  
  31. /* mem.h - defs for fixed size block memory allocator */
  32.  
  33. typedef long Align;
  34.  
  35. union freelist {
  36.     union freelist *next;    /* next block on freelist */
  37.     char memory;        /* user data */
  38.     Align aligner;        /* force alignment of blocks */
  39. };
  40.  
  41. typedef union freelist Freelist;
  42.  
  43. struct freelist_head {
  44.     int size_elt;        /* size of a single elt */
  45. #ifndef NOSTAT
  46.     int alloc;        /* # of allocations */
  47.     int dealloc;
  48.     int create;        /* number of calls to create a new freelist */
  49.     Generic max;        /* end of freelist */
  50. #endif
  51.     int size;        /* size of a single elt incl. next ptr */
  52.     int bytes;        /* if we run out, allocate memory by this
  53.                    many bytes */
  54.     Freelist *freelist;
  55. #if SPACE_PROFILE
  56.     int count;
  57. #endif
  58. };
  59.  
  60. char *new1;
  61.  
  62. #include "error.h"
  63.  
  64. /* should be MEMORY_C but there is none, so we'll tie it to express.c */
  65. #ifdef EXPRESS_C
  66. #include "defstart.h"
  67. #else
  68. #include "decstart.h"
  69. #endif /* EXPRESS_C */
  70.  
  71. /***********************************************/
  72. /* space allocation macros with error package: */
  73. /***********************************************/
  74.  
  75. extern int yylineno;
  76.  
  77. /* CALLOC grabs and initializes to all 0s space for the indicated */
  78. /* number of instances of the indicated type */
  79. #define    CALLOC(ptr, num, type)                    \
  80.     if (((ptr) = (type*)calloc((num), (unsigned)sizeof(type)))==NULL) {    \
  81.         fprintf(stderr,"fedex: out of space");\
  82.     } else {}
  83.  
  84. void    _MEMinitialize PROTO((void));
  85. void    MEMinitialize PROTO((struct freelist_head *,int,int,int));
  86. void    MEM_destroy PROTO((  struct freelist_head *,Freelist *));
  87. Generic    MEM_new PROTO((      struct freelist_head *));
  88.  
  89. #include "de_end.h"
  90.  
  91. #endif /* MEMORY_H */
  92.  
  93.  
  94.