[project @ 1998-11-26 09:17:22 by sof]
[ghc-hetmet.git] / ghc / lib / std / cbits / allocMem.lc
1 %
2 %
3 % (c) The GRASP/AQUA Project, Glasgow University, 1998
4 %
5 \subsection[allocMem.lc]{Allocating memory off heap}
6
7 \begin{code}
8
9 #include "rtsdefs.h"
10 #include "stgio.h"
11
12 StgAddr
13 allocMemory__(sz)
14 StgInt sz;/* bytes*/
15 {
16  StgAddr ptr;
17
18  if ( (ptr = malloc(sz*sizeof(char))) == NULL) {
19         ghc_errtype = ERR_RESOURCEEXHAUSTED;
20         ghc_errstr  = "malloc failed";
21         return NULL;
22  }
23  return ptr;
24
25 }
26
27 \end{code}