Source:NetHack 1.3d/alloc.c

Below is the full text to alloc.c from the source code of NetHack 1.3d. To link to a particular line, write [[NetHack 1.3d/alloc.c#line123 ]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

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