diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2016-09-18 13:46:29 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2016-09-18 13:46:29 +0000 |
commit | a21e7f69543f2cea9b69055c5ea8898aba83ef7d (patch) | |
tree | 7ed9ea29673bb194fa69821ee99ab296e398abb5 /lib | |
parent | 91698967a5a46c17c132557a1dd012948ef1e0f0 (diff) |
move page junking tp unmap(), right before we stick the region in the cache;
ok tedu@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdlib/malloc.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index ce869412f5b..0296985e5b5 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.195 2016/09/01 10:41:02 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.196 2016/09/18 13:46:28 otto Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> @@ -376,6 +376,11 @@ unmap(struct dir_info *d, void *p, size_t sz) for (i = 0; i < mopts.malloc_cache; i++) { r = &d->free_regions[(i + offset) & (mopts.malloc_cache - 1)]; if (r->p == NULL) { + if (mopts.malloc_junk && !mopts.malloc_freeunmap) { + size_t amt = mopts.malloc_junk == 1 ? + MALLOC_MAXCHUNK : sz; + memset(p, SOME_FREEJUNK, amt); + } if (mopts.malloc_hint) madvise(p, sz, MADV_FREE); if (mopts.malloc_freeunmap) @@ -1336,11 +1341,6 @@ ofree(struct dir_info *argpool, void *p) } STATS_SUB(pool->malloc_guarded, mopts.malloc_guard); } - if (mopts.malloc_junk && !mopts.malloc_freeunmap) { - size_t amt = mopts.malloc_junk == 1 ? MALLOC_MAXCHUNK : - PAGEROUND(sz) - mopts.malloc_guard; - memset(p, SOME_FREEJUNK, amt); - } unmap(pool, p, PAGEROUND(sz)); delete(pool, r); } else { |