projects
/
ghc-hetmet.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
dbc6fa3a4fd3e13acef3d8569ee55b2cc4d3c6ec
[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}