summaryrefslogtreecommitdiff
path: root/rts/RtsUtils.c
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2006-12-18 15:24:23 +0000
committerIan Lynagh <igloo@earth.li>2006-12-18 15:24:23 +0000
commit5f8b35ad729740cab1cb8c884deb405dcc758683 (patch)
treef509eb8d40a15ac4d6d0add80dbfec369f8de8db /rts/RtsUtils.c
parentf3109bb191b65c9c34bfaeb9d4b4e750f5b65ace (diff)
downloadhaskell-5f8b35ad729740cab1cb8c884deb405dcc758683.tar.gz
Don't overwrite old memory with 0xaa when doing a realloc
Diffstat (limited to 'rts/RtsUtils.c')
-rw-r--r--rts/RtsUtils.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c
index a2a2919702..a62a459be2 100644
--- a/rts/RtsUtils.c
+++ b/rts/RtsUtils.c
@@ -136,7 +136,7 @@ static void addAllocation(void *addr, size_t len) {
}
}
-static void removeAllocation(void *addr) {
+static void removeAllocation(void *addr, int overwrite_with_aa) {
Allocated *prev, *a;
if (addr == NULL) {
@@ -150,7 +150,9 @@ static void removeAllocation(void *addr) {
while (a != NULL) {
if (a->addr == addr) {
prev->next = a->next;
- memset(addr, 0xaa, a->len);
+ if (overwrite_with_aa) {
+ memset(addr, 0xaa, a->len);
+ }
free(a);
RELEASE_LOCK(&allocator_mutex);
return;
@@ -210,7 +212,7 @@ stgReallocBytes (void *p, int n, char *msg)
stg_exit(EXIT_INTERNAL_ERROR);
}
#if defined(DEBUG)
- removeAllocation(p);
+ removeAllocation(p, 0);
addAllocation(space, n2);
#endif
return space;
@@ -239,7 +241,7 @@ void
stgFree(void* p)
{
#if defined(DEBUG)
- removeAllocation(p);
+ removeAllocation(p, 1);
#endif
free(p);
}