pc-hack

PC HACK 3.61 source code (archival)
git clone http://frotz.net/git/pc-hack.git
Log | Files | Refs

alloc.c (829B)


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