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.3 2004/11/06 12:29:17 eirikn Exp $ */ 4 5 #include <stdlib.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 #include <stdio.h> 17 long * 18 alloc(n) unsigned n; { 19 long dummy = ftell(stderr); 20 if(n) dummy = 0; /* make sure arg is used */ 21 return(&dummy); 22 } 23 24 #else 25 26 long * 27 alloc(lth) 28 unsigned lth; 29 { 30 char *ptr; 31 32 if(!(ptr = malloc(lth))) 33 panic("Cannot get %d bytes", lth); 34 return((long *) ptr); 35 } 36 37 long * 38 enlarge(ptr,lth) 39 char *ptr; 40 unsigned lth; 41 { 42 char *nptr; 43 44 if(!(nptr = realloc(ptr,lth))) 45 panic("Cannot reallocate %d bytes", lth); 46 return((long *) nptr); 47 } 48 49 #endif /* LINT */ 50