summaryrefslogtreecommitdiff
path: root/malloc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2011-07-26 15:46:13 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 15:46:13 +0200
commit1b159c5602737076356b862a8d2205bb13b34909 (patch)
tree5f2cfffa8f8ab056fdd895285801a006519be135 /malloc.c
parent8c9e394bc270dbaa121f3f0af5a68c2876ab3fff (diff)
gc6.3alpha4 tarball importgc6_3alpha4
Diffstat (limited to 'malloc.c')
-rw-r--r--malloc.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/malloc.c b/malloc.c
index f5c8f06..edcbbc5 100644
--- a/malloc.c
+++ b/malloc.c
@@ -62,14 +62,14 @@ unsigned flags;
if (h == 0) {
result = 0;
} else {
- int total_bytes = BYTES_TO_WORDS(n_blocks * HBLKSIZE);
+ int total_bytes = n_blocks * HBLKSIZE;
if (n_blocks > 1) {
- GC_large_allocd_bytes += n_blocks * HBLKSIZE;
+ GC_large_allocd_bytes += total_bytes;
if (GC_large_allocd_bytes > GC_max_large_allocd_bytes)
GC_max_large_allocd_bytes = GC_large_allocd_bytes;
}
result = (ptr_t) (h -> hb_body);
- GC_words_wasted += total_bytes - lw;
+ GC_words_wasted += BYTES_TO_WORDS(total_bytes) - lw;
}
return result;
}
@@ -311,6 +311,19 @@ DCL_LOCK_STATE;
}
# ifdef REDIRECT_MALLOC
+
+/* Avoid unnecessary nested procedure calls here, by #defining some */
+/* malloc replacements. Otherwise we end up saving a */
+/* meaningless return address in the object. It also speeds things up, */
+/* but it is admittedly quite ugly. */
+# ifdef GC_ADD_CALLER
+# define RA GC_RETURN_ADDR,
+# else
+# define RA
+# endif
+# define GC_debug_malloc_replacement(lb) \
+ GC_debug_malloc(lb, RA "unknown", 0)
+
# ifdef __STDC__
GC_PTR malloc(size_t lb)
# else
@@ -363,6 +376,8 @@ DCL_LOCK_STATE;
/* and thus the right thing will happen even without overriding it. */
/* This seems to be true on most Linux systems. */
+#undef GC_debug_malloc_replacement
+
# endif /* REDIRECT_MALLOC */
/* Explicitly deallocate an object p. */