Pristine Ack-5.5
[Ack-5.5.git] / modules / src / alloc / alloc.h
1 /* $Id: alloc.h,v 1.14 1994/06/24 11:06:36 ceriel Exp $ */
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
10 /*      This file serves as the interface between the program and the
11         memory allocating routines.
12         There are 3 memory allocation routines:
13                 char *Malloc(n)         allocate n bytes
14                 char *Salloc(str, n)    allocate n bytes and fill them with
15                                         string str
16                 char *Realloc(str, n)   reallocate the block at str to n bytes.
17                 char *Srealloc(str, n)  same as Realloc.
18 */
19
20 #if __STDC__
21 char *Malloc(unsigned int);
22 char *Salloc(char *, unsigned int);
23 char *Srealloc(char *, unsigned int);
24 char *Realloc(char *, unsigned int);
25 char *st_alloc(char **, unsigned int, int);
26 char *std_alloc(char **, unsigned int, int, int *);
27 void No_Mem(void);
28 void clear(char *, unsigned int);
29 void botch(char *, unsigned int);
30 #else
31 extern char     *Salloc(), *Malloc(), *Srealloc(), *Realloc();
32 extern char     *st_alloc(), *std_alloc();
33 void            clear(), botch(), No_Mem();
34 #endif
35
36 /*      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        */
37
38 typedef struct _ALLOC_ {
39         struct _ALLOC_ *_A_next;
40 } *_PALLOC_;
41
42
43 #define _A_st_free(ptr, phead, size)    (((_PALLOC_)ptr)->_A_next = \
44                                                 (_PALLOC_)(*phead), \
45                                          *((_PALLOC_ *)phead) = \
46                                                 (_PALLOC_) ptr)
47 #ifndef BOTCH_FREE
48 #define st_free(ptr, phead, size)       _A_st_free(ptr, phead, size)
49 #else   /* def BOTCH_FREE */
50 #define st_free(ptr, phead, size)       (botch((char *)(ptr), size), \
51                                                 _A_st_free(ptr, phead, size))
52 #endif  /* BOTCH_FREE */
53
54 #define Free(p) free(p)
55
56 #endif /* __ALLOC_INCLUDED__ */