386BSD 0.1 development
[unix-history] / usr / src / usr.bin / awk / zmalloc.h
CommitLineData
a7e60862
WJ
1
2/********************************************
3zmalloc.h
4copyright 1991, Michael D. Brennan
5
6This is a source file for mawk, an implementation of
7the AWK programming language.
8
9Mawk is distributed without warranty under the terms of
10the GNU General Public License, version 2, 1991.
11********************************************/
12
13/*$Log: zmalloc.h,v $
14 * Revision 5.1 91/12/05 07:59:41 brennan
15 * 1.1 pre-release
16 *
17*/
18
19/* zmalloc.h */
20
21#ifndef ZMALLOC_H
22#define ZMALLOC_H
23
24#if ! HAVE_STDLIB_H
25char *malloc() , *realloc() ;
26void free() ;
27#endif
28
29
30PTR PROTO( bmalloc, (unsigned) ) ;
31void PROTO( bfree, (PTR, unsigned) ) ;
32PTR PROTO( zrealloc , (PTR,unsigned,unsigned) ) ;
33
34
35#define ZBLOCKSZ 8
36#define ZSHIFT 3
37
38
39#define zmalloc(size) bmalloc((((unsigned)size)+ZBLOCKSZ-1)>>ZSHIFT)
40#define zfree(p,size) bfree(p,(((unsigned)size)+ZBLOCKSZ-1)>>ZSHIFT)
41
42#define ZMALLOC(type) ((type*)zmalloc(sizeof(type)))
43#define ZFREE(p) zfree(p,sizeof(*(p)))
44
45
46#endif /* ZMALLOC_H */