0099ce86b72e0a600c71b39bb8e11734aa5eb14f
[games.git] / games / hack / alloc.c
1 /* alloc.c - version 1.0.2 */
2 /* $FreeBSD: src/games/hack/alloc.c,v 1.4 1999/11/16 02:57:01 billf Exp $ */
3 /* $DragonFly: src/games/hack/alloc.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */
4
5 #include "hack.h"
6
7 #ifdef LINT
8
9 /*
10    a ridiculous definition, suppressing
11         "possible pointer alignment problem" for (long *) malloc()
12         "enlarg defined but never used"
13         "ftell defined (in <stdio.h>) but never used"
14    from lint
15 */
16 long *
17 alloc(size_t n)
18 {
19         long dummy = ftell(stderr);
20
21         if (n)
22                 dummy = 0;      /* make sure arg is used */
23         return (&dummy);
24 }
25
26 #else
27
28 void *
29 alloc(size_t lth)
30 {
31         void *ptr;
32
33         if ((ptr = malloc(lth)) == NULL)
34                 panic("Cannot get %d bytes", lth);
35         return (ptr);
36 }
37
38 #endif /* LINT */