|
8 | 8 | /* PROGRAM'S INTERFACE TO MEMORY ALLOCATION ROUTINES */ |
9 | 9 |
|
10 | 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 |
| 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 | 16 | */ |
17 | 17 |
|
18 | | -char *Salloc(char *, unsigned int); |
19 | | -char *st_alloc(char **, unsigned int, int); |
20 | | -char *std_alloc(char **, unsigned int, int, int *); |
21 | | -void clear(char *, unsigned int); |
22 | | -void botch(char *, unsigned int); |
| 18 | +char* Salloc(char*, unsigned int); |
| 19 | +char* st_alloc(char**, unsigned int, int); |
| 20 | +char* std_alloc(char**, unsigned int, int, int*); |
| 21 | +void clear(char*, unsigned int); |
| 22 | +void botch(char*, unsigned int); |
23 | 23 |
|
24 | 24 | /* 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 */ |
25 | 25 |
|
26 | | -typedef struct _ALLOC_ { |
27 | | - struct _ALLOC_ *_A_next; |
28 | | -} *_PALLOC_; |
| 26 | +typedef struct _ALLOC_ |
| 27 | +{ |
| 28 | + struct _ALLOC_* _A_next; |
| 29 | +}* _PALLOC_; |
29 | 30 |
|
30 | | - |
31 | | -#define _A_st_free(ptr, phead, size) (((_PALLOC_)ptr)->_A_next = \ |
32 | | - (_PALLOC_)(*phead), \ |
33 | | - *((_PALLOC_ *)phead) = \ |
34 | | - (_PALLOC_) ptr) |
35 | | -#ifndef BOTCH_FREE |
36 | | -#define st_free(ptr, phead, size) _A_st_free(ptr, phead, size) |
37 | | -#else /* def BOTCH_FREE */ |
38 | | -#define st_free(ptr, phead, size) (botch((char *)(ptr), size), \ |
39 | | - _A_st_free(ptr, phead, size)) |
40 | | -#endif /* BOTCH_FREE */ |
| 31 | +#define _A_st_free(ptr, phead, size) \ |
| 32 | + (((_PALLOC_)ptr)->_A_next = (_PALLOC_)(*phead), *((_PALLOC_*)phead) = (_PALLOC_)ptr) |
| 33 | +#ifndef BOTCH_FREE |
| 34 | +#define st_free(ptr, phead, size) _A_st_free(ptr, phead, size) |
| 35 | +#else /* def BOTCH_FREE */ |
| 36 | +#define st_free(ptr, phead, size) (botch((char*)(ptr), size), _A_st_free(ptr, phead, size)) |
| 37 | +#endif /* BOTCH_FREE */ |
41 | 38 |
|
42 | 39 | #endif /* __ALLOC_INCLUDED__ */ |
0 commit comments