xref: /csrg-svn/games/hack/alloc.c (revision 41206)
1*41206Sbostic /* alloc.c - version 1.0.2 */
2*41206Sbostic #ifdef LINT
3*41206Sbostic 
4*41206Sbostic /*
5*41206Sbostic    a ridiculous definition, suppressing
6*41206Sbostic 	"possible pointer alignment problem" for (long *) malloc()
7*41206Sbostic 	"enlarg defined but never used"
8*41206Sbostic 	"ftell defined (in <stdio.h>) but never used"
9*41206Sbostic    from lint
10*41206Sbostic */
11*41206Sbostic #include <stdio.h>
12*41206Sbostic long *
alloc(n)13*41206Sbostic alloc(n) unsigned n; {
14*41206Sbostic long dummy = ftell(stderr);
15*41206Sbostic 	if(n) dummy = 0;	/* make sure arg is used */
16*41206Sbostic 	return(&dummy);
17*41206Sbostic }
18*41206Sbostic 
19*41206Sbostic #else
20*41206Sbostic 
21*41206Sbostic extern char *malloc();
22*41206Sbostic extern char *realloc();
23*41206Sbostic 
24*41206Sbostic long *
alloc(lth)25*41206Sbostic alloc(lth)
26*41206Sbostic register unsigned lth;
27*41206Sbostic {
28*41206Sbostic 	register char *ptr;
29*41206Sbostic 
30*41206Sbostic 	if(!(ptr = malloc(lth)))
31*41206Sbostic 		panic("Cannot get %d bytes", lth);
32*41206Sbostic 	return((long *) ptr);
33*41206Sbostic }
34*41206Sbostic 
35*41206Sbostic long *
enlarge(ptr,lth)36*41206Sbostic enlarge(ptr,lth)
37*41206Sbostic register char *ptr;
38*41206Sbostic register unsigned lth;
39*41206Sbostic {
40*41206Sbostic 	register char *nptr;
41*41206Sbostic 
42*41206Sbostic 	if(!(nptr = realloc(ptr,lth)))
43*41206Sbostic 		panic("Cannot reallocate %d bytes", lth);
44*41206Sbostic 	return((long *) nptr);
45*41206Sbostic }
46*41206Sbostic 
47*41206Sbostic #endif LINT
48