Fandom

Wikihack

Source:NetHack 3.1.0/alloc.c

2,034pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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

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

The NetHack General Public License applies to screenshots, source code and other content from NetHack.
1.    /*	SCCS Id: @(#)alloc.c	3.1	90/22/02
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
5.    /* to get the malloc() prototype from system.h */
6.    #define ALLOC_C		/* comment line for pre-compiled headers */
7.    /* since this file is also used in auxiliary programs, don't include all the 
8.     * function declarations for all of nethack
9.     */
10.   #define EXTERN_H	/* comment line for pre-compiled headers */
11.   #include "config.h"
12.   long *FDECL(alloc,(unsigned int));
13.   
14.   #ifdef LINT
15.   /*
16.      a ridiculous definition, suppressing
17.   	"possible pointer alignment problem" for (long *) malloc()
18.      from lint
19.   */
20.   long *
21.   alloc(n) unsigned int n; {
22.   long dummy = ftell(stderr);
23.   	if(n) dummy = 0;	/* make sure arg is used */
24.   	return(&dummy);
25.   }
26.   
27.   #else
28.   #ifndef __TURBOC__
29.   extern void VDECL(panic, (const char *,...)) PRINTF_F(1,2);
30.   
31.   long *
32.   alloc(lth)
33.   register unsigned int lth;
34.   {
35.   	register genericptr_t ptr;
36.   
37.   	if(!(ptr = malloc(lth)))
38.   		panic("Cannot get %d bytes", lth);
39.   	return((long *) ptr);
40.   }
41.   #endif
42.   
43.   #endif /* LINT /**/
44.   
45.   /*alloc.c*/

Also on Fandom

Random Wiki