alloc.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. #ifndef __ALLOC_INCLUDED__
  7. #define __ALLOC_INCLUDED__
  8. /* PROGRAM'S INTERFACE TO MEMORY ALLOCATION ROUTINES */
  9. /* This file serves as the interface between the program and the
  10. memory allocating routines.
  11. There are 3 memory allocation routines:
  12. char *Malloc(n) allocate n bytes
  13. char *Salloc(str, n) allocate n bytes and fill them with
  14. string str
  15. char *Realloc(str, n) reallocate the block at str to n bytes.
  16. char *Srealloc(str, n) same as Realloc.
  17. */
  18. #if __STDC__
  19. char *Malloc(unsigned int);
  20. char *Salloc(char *, unsigned int);
  21. char *Srealloc(char *, unsigned int);
  22. char *Realloc(char *, unsigned int);
  23. char *st_alloc(char **, unsigned int, int);
  24. char *std_alloc(char **, unsigned int, int, int *);
  25. void No_Mem(void);
  26. void clear(char *, unsigned int);
  27. void botch(char *, unsigned int);
  28. #else
  29. extern char *Salloc(), *Malloc(), *Srealloc(), *Realloc();
  30. extern char *st_alloc(), *std_alloc();
  31. void clear(), botch(), No_Mem();
  32. #endif
  33. /* S T R U C T U R E - S T O R A G E D E F I N I T I O N S */
  34. typedef struct _ALLOC_ {
  35. struct _ALLOC_ *_A_next;
  36. } *_PALLOC_;
  37. #define _A_st_free(ptr, phead, size) (((_PALLOC_)ptr)->_A_next = \
  38. (_PALLOC_)(*phead), \
  39. *((_PALLOC_ *)phead) = \
  40. (_PALLOC_) ptr)
  41. #ifndef BOTCH_FREE
  42. #define st_free(ptr, phead, size) _A_st_free(ptr, phead, size)
  43. #else /* def BOTCH_FREE */
  44. #define st_free(ptr, phead, size) (botch((char *)(ptr), size), \
  45. _A_st_free(ptr, phead, size))
  46. #endif /* BOTCH_FREE */
  47. #define Free(p) free(p)
  48. #endif /* __ALLOC_INCLUDED__ */