summaryrefslogtreecommitdiffstats
path: root/include/jemalloc
diff options
context:
space:
mode:
authorGuilherme Goncalves <guilherme.p.gonc@gmail.com>2014-12-08 21:12:41 (GMT)
committerJason Evans <jasone@canonware.com>2014-12-15 01:07:26 (GMT)
commit2c5cb613dfbdf58f88152321b63e60c58cd23972 (patch)
tree9c32a6519cb435203141d19a0c0f60fa111803e0 /include/jemalloc
parentb74041fb6e279bd8bbc133250241249f90cd619f (diff)
downloadjemalloc-2c5cb613dfbdf58f88152321b63e60c58cd23972.zip
jemalloc-2c5cb613dfbdf58f88152321b63e60c58cd23972.tar.gz
jemalloc-2c5cb613dfbdf58f88152321b63e60c58cd23972.tar.bz2
Introduce two new modes of junk filling: "alloc" and "free".
In addition to true/false, opt.junk can now be either "alloc" or "free", giving applications the possibility of junking memory only on allocation or deallocation. This resolves #172.
Diffstat (limited to 'include/jemalloc')
-rw-r--r--include/jemalloc/internal/jemalloc_internal.h.in4
-rw-r--r--include/jemalloc/internal/private_symbols.txt2
-rw-r--r--include/jemalloc/internal/tcache.h10
3 files changed, 10 insertions, 6 deletions
diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
index 9bd501c..b7617df 100644
--- a/include/jemalloc/internal/jemalloc_internal.h.in
+++ b/include/jemalloc/internal/jemalloc_internal.h.in
@@ -376,7 +376,9 @@ typedef unsigned index_t;
#define JEMALLOC_H_EXTERNS
extern bool opt_abort;
-extern bool opt_junk;
+extern const char *opt_junk;
+extern bool opt_junk_alloc;
+extern bool opt_junk_free;
extern size_t opt_quarantine;
extern bool opt_redzone;
extern bool opt_utrace;
diff --git a/include/jemalloc/internal/private_symbols.txt b/include/jemalloc/internal/private_symbols.txt
index ee973c9..7e33915 100644
--- a/include/jemalloc/internal/private_symbols.txt
+++ b/include/jemalloc/internal/private_symbols.txt
@@ -274,6 +274,8 @@ nhbins
opt_abort
opt_dss
opt_junk
+opt_junk_alloc
+opt_junk_free
opt_lg_chunk
opt_lg_dirty_mult
opt_lg_prof_interval
diff --git a/include/jemalloc/internal/tcache.h b/include/jemalloc/internal/tcache.h
index 3a3fd49..6e97b3d 100644
--- a/include/jemalloc/internal/tcache.h
+++ b/include/jemalloc/internal/tcache.h
@@ -252,14 +252,14 @@ tcache_alloc_small(tcache_t *tcache, size_t size, bool zero)
if (likely(!zero)) {
if (config_fill) {
- if (unlikely(opt_junk)) {
+ if (unlikely(opt_junk_alloc)) {
arena_alloc_junk_small(ret,
&arena_bin_info[binind], false);
} else if (unlikely(opt_zero))
memset(ret, 0, usize);
}
} else {
- if (config_fill && unlikely(opt_junk)) {
+ if (config_fill && unlikely(opt_junk_alloc)) {
arena_alloc_junk_small(ret, &arena_bin_info[binind],
true);
}
@@ -307,7 +307,7 @@ tcache_alloc_large(tcache_t *tcache, size_t size, bool zero)
}
if (likely(!zero)) {
if (config_fill) {
- if (unlikely(opt_junk))
+ if (unlikely(opt_junk_alloc))
memset(ret, 0xa5, usize);
else if (unlikely(opt_zero))
memset(ret, 0, usize);
@@ -333,7 +333,7 @@ tcache_dalloc_small(tcache_t *tcache, void *ptr, index_t binind)
assert(tcache_salloc(ptr) <= SMALL_MAXCLASS);
- if (config_fill && unlikely(opt_junk))
+ if (config_fill && unlikely(opt_junk_free))
arena_dalloc_junk_small(ptr, &arena_bin_info[binind]);
tbin = &tcache->tbins[binind];
@@ -362,7 +362,7 @@ tcache_dalloc_large(tcache_t *tcache, void *ptr, size_t size)
binind = size2index(size);
- if (config_fill && unlikely(opt_junk))
+ if (config_fill && unlikely(opt_junk_free))
arena_dalloc_junk_large(ptr, size);
tbin = &tcache->tbins[binind];