From 814803d97eb7d355bfc429c40b375fc52bf4799a Mon Sep 17 00:00:00 2001 From: otto <> Date: Sun, 18 Sep 2016 13:46:28 +0000 Subject: [PATCH] move page junking tp unmap(), right before we stick the region in the cache; ok tedu@ --- src/lib/libc/stdlib/malloc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index ce869412..0296985e 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/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 * Copyright (c) 2012 Matthew Dempsky @@ -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 {