From: simonmar Date: Fri, 16 Dec 2005 11:26:01 +0000 (+0000) Subject: [project @ 2005-12-16 11:26:01 by simonmar] X-Git-Tag: final_switch_to_darcs,_this_repo_is_now_live~88 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=28cb5a23923dec35e463a6296171cb6f30f3dc1e;hp=12694df2b002fe264d1e9e8209e0fbb6914ffe50;p=ghc-hetmet.git [project @ 2005-12-16 11:26:01 by simonmar] Use standard calloc rather than rolling our own. As a small bonus, the standard libc version is more effecient about zeroing the memory. From: Duncan Coutts --- diff --git a/ghc/rts/RtsUtils.c b/ghc/rts/RtsUtils.c index a448c3e..b54d3da 100644 --- a/ghc/rts/RtsUtils.c +++ b/ghc/rts/RtsUtils.c @@ -91,11 +91,14 @@ stgReallocBytes (void *p, int n, char *msg) void * stgCallocBytes (int n, int m, char *msg) { - int i; - int sz = n * m; - char* p = stgMallocBytes(sz, msg); - for (i = 0; i < sz; i++) p[i] = 0; - return p; + char *space; + + if ((space = (char *) calloc((size_t) n, (size_t) m)) == NULL) { + /* don't fflush(stdout); WORKAROUND bug in Linux glibc */ + MallocFailHook((W_) n*m, msg); /*msg*/ + stg_exit(EXIT_INTERNAL_ERROR); + } + return space; } /* To simplify changing the underlying allocator used