home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d190 / nethack.lha / NetHack / een.zoo / alloc.c next >
C/C++ Source or Header  |  1988-07-01  |  908b  |  51 lines

  1. /*    SCCS Id: @(#)alloc.c    1.4    87/08/08
  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 <stdio.h>) but never used"
  10.    from lint
  11. */
  12. #include <stdio.h>
  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 /**/
  51.