ALLOCATE.C 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Allocate and clear storage for bison,
  2. Copyright (C) 1984, 1989 Free Software Foundation, Inc.
  3. This file is part of Bison, the GNU Compiler Compiler.
  4. Bison is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 1, or (at your option)
  7. any later version.
  8. Bison is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with Bison; see the file COPYING. If not, write to
  14. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  15. #include <stdio.h>
  16. extern char *calloc();
  17. extern void done();
  18. char *
  19. mallocate(n)
  20. register unsigned n;
  21. {
  22. register char *block;
  23. block = calloc(n,1);
  24. if (block == NULL)
  25. {
  26. fprintf(stderr, "bison: memory exhausted\n");
  27. done(1);
  28. }
  29. return (block);
  30. }
  31. /* This name is used by alloca.c. */
  32. char *
  33. xmalloc (n)
  34. unsigned int n;
  35. {
  36. return mallocate (n);
  37. }