home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / online / source / c / compilers / Bison.sit.hqx / Bison / Source / allocate.c next >
Text File  |  1992-08-22  |  2KB  |  62 lines

  1. /***********************************************************
  2.  *
  3.  * Macintosh/MPW version of GNU Bison 1.18
  4.  * Please read the README_MPW file for more information
  5.  *
  6.  ***********************************************************/
  7.  
  8. /* Allocate and clear storage for bison,
  9.    Copyright (C) 1984, 1989 Free Software Foundation, Inc.
  10.  
  11. This file is part of Bison, the GNU Compiler Compiler.
  12.  
  13. Bison is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2, or (at your option)
  16. any later version.
  17.  
  18. Bison is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with Bison; see the file COPYING.  If not, write to
  25. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  26.  
  27.  
  28. #include <stdio.h>
  29.  
  30. extern char *calloc();
  31. extern void done();
  32.  
  33. extern char *program_name;
  34.  
  35. char *
  36. mallocate(n)
  37. register unsigned n;
  38. {
  39.   register char *block;
  40.  
  41.   /* Avoid uncertainty about what an arg of 0 will do.  */
  42.   if (n == 0)
  43.     n = 1;
  44.   block = calloc(n,1);
  45.   if (block == NULL)
  46.     {
  47.       fprintf(stderr, "%s: memory exhausted\n", program_name);
  48.       done(1);
  49.     }
  50.  
  51.   return (block);
  52. }
  53.  
  54. /* This name is used by alloca.c.  */
  55.  
  56. char *
  57. xmalloc (n)
  58.      unsigned int n;
  59. {
  60.   return mallocate (n);
  61. }
  62.