[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / runtime / storage / SMalloc.lc
1 [
2  SMalloc seems a BAD choice of name.  I expected this to be the routines I
3  could use to allocate memory, not those used by the storage manager internally.
4
5  KH
6 ]
7
8 Routines that deal with memory allocation:
9
10 All dynamic allocation must be done before the stacks and heap are
11 allocated. This allows us to use the lower level sbrk routines if
12 required.
13
14 \begin{code}
15 #define NULL_REG_MAP
16 #include "SMinternal.h"
17
18 /* Return a ptr to n StgWords (note: WORDS not BYTES!) or die miserably */
19 /* ToDo: Should allow use of valloc to allign on page boundary */
20
21 char *
22 #ifdef __STDC__
23 xmalloc(size_t n)
24 #else
25 xmalloc(n)
26     size_t n;
27 #endif
28 {
29     char *space;
30
31     if ((space = (char *) malloc(n)) == NULL) {
32         MallocFailHook((W_) n); /*msg*/
33         EXIT(EXIT_FAILURE);
34     }
35     return space;
36 }
37 \end{code}