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